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 does this mean ? GRANT BIND,EXECUTE ON PLAN MK2 TO PUBLIC;

4 Answers   Accenture,


Which command is used to connect to a database in DB2 ? Give the Syntax.

0 Answers   MCN Solutions,


What information can you find in SYSIBM.SYSLINKS table?

1 Answers   TCS,


What is load utility in db2?

0 Answers  


How we create a tables in DB2 ?Previously client has using 7 letters for user id,now he wants to increase the letters from 7 to 12 for user id.How we can do it?

6 Answers   Wipro,






what needs to be done if a table is in copy pending / check pending status?

5 Answers   Xansa,


What is the clustering index in the db2 database?

0 Answers  


why we create view.

5 Answers  


What is the purpose of the WHENEVER statement?

1 Answers  


What is the use of db2?

0 Answers  


What is isolation level?

4 Answers  


What is dbrm? When it will be created?

0 Answers  


Categories