I have a large query, but my biggest problem lies in this small portion.
ItemID is foreign keyed to the Master Item table – it is not unique. This query doesn’t do what I want (row can’t have all 4 names) but it illustrates what I’m looking for.
Select masteritemid from itemsgrouptable
where itemname like 'Item 1'
And itemname like 'Item 2'
And itemname like 'Item 3'
And itemname like 'Item 4'
I want to pull an itemid only if the 4 listed records exist with that ID. My current method joins the same table together 4 times based on ID, with each section looking at 1 string… it is HIGHLY inefficient.
Use a regex match:
This will match any itemname starting with either “Item 1” or “Item 2” or “Item 3” or “Item 4”