MySQL Forums
Forum List  »  MySQL Workbench

Re: Need modeling help
Posted by: Mike Lischke
Date: April 14, 2009 01:34AM


what you are asking here is not about MySQL Workbench, but general SQL help for which we have dedicated forums too. What you are after seems something like this:

select storeId from stocks where itemId in (1, 4)
group by storeId
having count(*) = 2;

Given the table structure I laid out in my first reply this query will return a list of stores which offer the items 1 and 4 currently. The number in the "having" clause corresponds to the number of entries in the "in" clause. By varying the "having" clause you can easily ask for other information like, which stores has exactly or at least n items given in the list etc.

For more detailed answers about SQL syntax in general I recommend asking in the specialized forums for such questions.


Mike Lischke, MySQL Developer Tools
Oracle Corporation

MySQL Workbench on Github:
On Twitter:
On Slack: (#workbench)
Report bugs to
MySQL documentation can be found here:

Options: ReplyQuote

Written By
April 05, 2009 08:10PM
April 06, 2009 01:21AM
April 06, 2009 06:54PM
April 07, 2009 10:18PM
April 11, 2009 08:36PM
Re: Need modeling help
April 14, 2009 01:34AM
April 17, 2009 07:03PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.