If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Usage of LIKE statement with wildcards

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-09, 14:35
maanas maanas is offline
Registered User
 
Join Date: Jan 2009
Posts: 4
Usage of LIKE statement with wildcards

Hi.

Have been a silent spectator of the forum for a while..

had a quick question.

can the LIKE be used with the Wildcard only at the beginning of the data.

for example, I need all records ending with 6343.

I Tried using
select (*) from abcd
where
Account LIKE '%6343'

but am not getting any records.

using like

select (*) from abcd
where
Account LIKE '%6343%'


lists all records containing 6343 which is not the result set i am looking for.

any suggestions?


thanks
Reply With Quote
  #2 (permalink)  
Old 01-29-09, 14:50
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
This could happen if the ACCOUNT column is defined as CHAR, in which case it may contain trailing spaces to fill the column value to the specified length. Try "RTRIM(ACCOUNT) LIKE '%6343'".
Reply With Quote
  #3 (permalink)  
Old 01-29-09, 14:56
maanas maanas is offline
Registered User
 
Join Date: Jan 2009
Posts: 4
Quote:
Originally Posted by n_i
This could happen if the ACCOUNT column is defined as CHAR, in which case it may contain trailing spaces to fill the column value to the specified length. Try "RTRIM(ACCOUNT) LIKE '%6343'".

thanks a lot..

now i feel dumb :P
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On