General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Finding ALL items not ANY
How do you find like all orders that included a hammer AND nails? This is assuming a table normalized like ORDITEMS in TESTDATA. That is one item per record. INLIST(orditems.item,"hammers","nails") works fine for an 'ANY' scenario but not an 'ALL'
I need a single SQL statement if possible that will allow for multiple selections from a listbox to be searched for in a normalized table in an ALL fashion. There may be more than 2 selections so I can't just use a subquery since that's limited to one level deep.
Do I use a self join? Add a column for each item and use GROUP BY ordernum HAVING something? I can do it with multiple SQL statements searching on one item at a time then joining the resultant cursor with the next one but if there's a way to do it in one I'd like it better. I'm building a string that is eventually macro expanded. Thanks!
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only