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.
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.
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%')
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.