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 the difference between TYPE 1 index & TYPE 2 index

1 Answers   IBM,


What is the maximum size of varchar data type in db2?

0 Answers  


What is a db2 table?

0 Answers  


What is check constraint in db2?

0 Answers  


Explain dclgen.

0 Answers  


Explain about dbrm.

0 Answers  


In case if at some point of time db2 is down, would that impact the pre-compilation process of a db2-cobol program?

0 Answers  


How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF? Give an example with a host variable in WHERE clause)

2 Answers  


How to see the structure of db2 table??

4 Answers   IBM,


Is it possible to alter a table – for example adding a column, when another user is accessing or updating some columns?

0 Answers  


What is the maximum length of sqlca?

0 Answers  


the dd name for ksds is dest1 and what is the dd name for alternate index of ksds ? a.dest b.dest1 c.dest1a d.dd1

2 Answers   Logica CMG,


Categories