I have a problem with mysql query, it’s complex problem which relates to Mysql join query for multiple "tags" (many-to-many relationship) that matches ALL tags?
So I have classic MN table schema:
Item
1 | Item1
2 | Item2
...
Category
1 | Category1
2 | Category2
3 | Category3
4 | Category4
...
Item_has_category
1 | 1
...
And question is – How can I get rows, where item has Category1 OR Category2 AND Category3?
It is for some complex filter and some categories has a special group, which must be with AND.
I suppose that I must combine HAVING with DISTINCT (link to another questions at top), but I’m not sure how.
This
group bywould work: