Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Like parameter in DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
MGayathri

New User


Joined: 19 May 2007
Posts: 21
Location: Chennai

PostPosted: Wed Nov 28, 2007 4:57 pm    Post subject: Like parameter in DB2
Reply with quote

How to retrieve records having % in a field using DB2 Like parameter

Example:
PCT
10%
100%
20
Back to top
View user's profile Send private message
References
PostPosted: Wed Nov 28, 2007 4:57 pm    Post subject: Re: Like parameter in DB2 Reply with quote

muthuvel

Active User


Joined: 29 Nov 2005
Posts: 178
Location: Chennai

PostPosted: Wed Nov 28, 2007 5:03 pm    Post subject: Reply to: Like parameter in DB2
Reply with quote

To search for a % or an _ as a literal part of your string, use the ESCAPE clause

Example-
Code:

   SELECT EMPNO, EMPNAME, WORKDEPT             FROM    EMP                                                            WHERE EMPNAME LIKE ‘ANURAG+_KAPOOR%'
                   ESCAPE ‘+’
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 182
Location: Bangalore

PostPosted: Wed Nov 28, 2007 5:43 pm    Post subject:
Reply with quote

MGayathri,

I think your requirement is to retrieve the records that have character "%" in any position in the column data.

If yes, please check with the following code for your requirement as muthuvel suggested.

Code:
SELECT COLUMN_NAME FROM TABLE_NAME  WHERE COLUMN_NAME LIKE '%+%%' ESCAPE '+'
Back to top
View user's profile Send private message
MGayathri

New User


Joined: 19 May 2007
Posts: 21
Location: Chennai

PostPosted: Wed Nov 28, 2007 10:25 pm    Post subject:
Reply with quote

Muthuvel and Shanker.. Thanks a lot..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1