I have 2 tables: players and items. Now I’m looking for player who has item with known properties ex.
SELECT players.`name` FROM `players`
INNER JOIN `items` ON players.`id`=items.`ownerId`
WHERE items.`itemType` = 1 AND items.`itemClass` = 2 AND items.`itemColor` = 3
How i can find player which has more than one item i want? It is even possible in one query?
Ex. i wanna find player which has both items : type=1 class=2 color=3 , type=2 class=3 color=4
I have an idea how to do it in multiple querys: just add players.id IN (…) on every next query.
Thanks for all your help!
The best way to do this is with aggregation.
If you want other information about the owner, you need to join in the players table.
In MySQL, you can simplify the
havingclause to: