Generally if I want to select the names starting with c I
need to use c%
But how could I code to select the data which contains %
as a part of data.

Answers were Sorted based on User's Feedback



Generally if I want to select the names starting with c I need to use c% But how could I code to..

Answer / mdvasanth86

Anand is right.


SELECT * FROM table_name WHERE column_name LIKE 'C!%'
ESCAPE'!';


If you want to use % or _ as part of your like clause,
you must have an escape character before each occurrence of
% or _ and define what the escape character is like above.

So, an escape character before the % or _ will make it part
of the string rather than a wildcard character(S).


HTH

Is This Answer Correct ?    3 Yes 0 No

Generally if I want to select the names starting with c I need to use c% But how could I code to..

Answer / bala

Use '%%' to select the data which contains %

Is This Answer Correct ?    7 Yes 5 No

Generally if I want to select the names starting with c I need to use c% But how could I code to..

Answer / guest

C% will work for all the cases. Even if the data contains
%, Using C% will fetch that too.

Is This Answer Correct ?    1 Yes 0 No

Generally if I want to select the names starting with c I need to use c% But how could I code to..

Answer / prachi

SELECT NAME FROM EMP WHERE NAME LIKE 'C%';

Is This Answer Correct ?    1 Yes 1 No

Generally if I want to select the names starting with c I need to use c% But how could I code to..

Answer / anand

hi,
it may be correct ans.check out this..
SELECT * FROM table_name WHERE column_name LIKE 'C%%'
ESCAPE'%';

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More DB2 Interview Questions

what is contained in the DB2 node lock file? A) data base names B) data base users names C) license keys D) server names

5 Answers   Accenture,


EXPLAIN has output with MATCHCOLS = 0. What does it mean?

2 Answers  


How does coalesce work?

1 Answers  


What is the syntax for seeing the columns and data types of a table in the db2 database?

1 Answers  


What is the usage of open cursor command?

1 Answers  


what are the copybook changes generally we done?can anyone tell me......... Thanks in advance........

1 Answers  


what is diffrence b/w file-aid tool and file-aid utility???

2 Answers  


Are views updatable ?

4 Answers  


AGGREGATE function support by DB2. A) SUM & AVG B) SUM, MIN & AVG C) SUM, MAX, AVG , MIN &COUNT D) NONE

2 Answers   Accenture,


What is db2 command?

1 Answers  


Why select is not preferred in embedded sql programs?

1 Answers  


How can record locking be achieved in those DB2 versions which do not support it?

1 Answers  


Categories