mysql joins - how to find all children that belongs to ALL parents

Posted by kimsia on Stack Overflow See other posts from Stack Overflow or by kimsia
Published on 2012-03-27T05:25:10Z Indexed on 2012/03/27 5:29 UTC
Read the original article Hit count: 182

Filed under:
|
|

I have three mysql tables

items
the columns are id, title

items_in_categories
the columns are id, item_id, category_id

categories
the columns are id, title

I want to find all the items that belong to ALL the stated categories. Not any one category, but ALL categories

Eg, if I want to search all the items that belongs to category id 3 and 5

I would like to use as simple a way as possible.

I have tried AND and a nested NOT EXISTS as stated in the mysql manual.

Nothing worked.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about inner-join