Results 1 to 2 of 2

Thread: DB2 query

  1. #1
    Join Date
    Nov 2006
    Posts
    1

    Unanswered: DB2 query

    hi
    i want use LIKE operator to compare two columns from two different tables in DB2 please help???

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    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/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •