Left Join using LIKE

  • What is the best way to join to tables from different db's using LIKE? I'm trying to match Tracking Codes where one table has the code for the visit and another table in a different db has all the tracking codes that map to a campaign (separated by , ). I've tried:

    C.Tracking_Code__c LIKE '''%'+A.TrackingCode+'%'''

    which does not work. Any thoughts?

  • Turns out I had too many ' this worked: A.TrackingCode LIKE '%'+A.TrackingCode+'%'

  • A better method would be to convert the comma-delimited column into a table and join on the table.

    You can search this site for many examples of how this can be done. I would also recommend that you look into using CROSS APPLY with this - as that just might work better.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply