Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding ALL items not ANY
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Finding ALL items not ANY
Miscellaneous
Thread ID:
00427146
Message ID:
00427146
Views:
51
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
Map
View

Click here to load this message in the networking platform