Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010
    Posts
    40

    Unanswered: joining on like instead of =

    Hi,
    I am writing a query where I want to join two tables but using like, instead of =.

    say the two columns are
    tb1.col1
    tb2.col2

    left join mytable2 tb2 on tb1.col1 like tb2.col2

    the problem is the values in tb2 will contain the value in tb1 so I really need something like

    left join mytabl2 tb2 on tb1.col1 like 'tb2.col2%' but in the ' ' , it will be interpreted as the string and not the table name.

    what am I missing?
    Thanks

  2. #2
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    Code:
    SELECT *
    FROM tb1
    JOIN tb2 ON tb1.col1 LIKE tb2.col2 || '%'

Posting Permissions

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