Home Forums SQL Server 2005 T-SQL (SS2K5) Help using LIKE and IN(select product from referenceTable) and wildcards RE: Help using LIKE and IN(select product from referenceTable) and wildcards

  • Take a look at this.

    A simple JOIN or EXISTS can do the trick.

    /* Return ALL records from @productList that are LIKE products in @softwareReferenceList */

    select p.*

    from @productList p

    JOIN @softwareReferenceList s ON p.Product LIKE s.Product

    /*where Product like in(select Product from @softwareReferenceList)*/

    order by 2

    select p.*

    from @productList p

    WHERE EXISTS( SELECT 1 FROM @softwareReferenceList s WHERE p.Product LIKE s.Product)

    /*where Product like in(select Product from @softwareReferenceList)*/

    order by 2

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2