Link to home
Start Free TrialLog in
Avatar of holemania
holemania

asked on

SQL Like with Multiple Values

I need to add a filter with multiple "Not LIke" in my query.  Similar to how you do it to like the "In" query.

Select *
From  Item_Master
Where Item_ID In ('ABC', 'DDD', '123GAS')

Issue is that the string for not like can be one or many and dynamic.  So I do not want to defy multiple "Not Like" in my query.
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

If you have a dynamic criteria you can only achieve this with a dynamic query (construct the query in runtime).
You will need to append and build the filter using or/and clauses
Select * from item_master where  not  (item_ID like 'AB%' or item_ID like 'DD%')

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Russell Fox
Russell Fox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of holemania
holemania

ASKER

Thank you.