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 > DB2 query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-06, 01:35
srika srika is offline
Registered User
 
Join Date: Nov 2006
Posts: 1
DB2 query

hi
i want use LIKE operator to compare two columns from two different tables in DB2 please help???
Reply With Quote
  #2 (permalink)  
Old 11-08-06, 02:08
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
You'll probably have to use SUBSTR and POSSTR or something like that, since there is no generic concept of "string is like an other string".

E.g., if you want to check whether the first and third bytes are identical (but possibly not the second one):
Code:
WHERE substr(col1,1,1)=substr(col2,1,1) AND substr(col1,3,1)=substr(col2,3,1)
If the start point of the match is not fixed but depends on the contents (say: identical after the first "."), combine substr() with posstr():
Code:
WHERE substr(col1,posstr(col1,'.')) = substr(col2,posstr(col2,'.'))
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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