MySQL Forums
Forum List  »  MySQL Workbench

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

Richard,

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

Mike Lischke, MySQL Developer Tools
Oracle Corporation

MySQL Workbench on Github: https://github.com/mysql/mysql-workbench
On Twitter: https://twitter.com/MySQLWorkbench
On Slack: mysqlcommunity.slack.com (#workbench)
Report bugs to http://bugs.mysql.com
MySQL documentation can be found here: http://dev.mysql.com/doc/refman/8.0/en/

Options: ReplyQuote


Subject
Views
Written By
Posted
2697
April 05, 2009 08:10PM
2429
April 06, 2009 01:21AM
2242
April 06, 2009 06:54PM
2176
April 07, 2009 10:18PM
2051
April 11, 2009 08:36PM
Re: Need modeling help
2226
April 14, 2009 01:34AM
1992
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.