MySQL: List rows who have one but not another many-to-many relationship
Posted
by
Svish
on Stack Overflow
See other posts from Stack Overflow
or by Svish
Published on 2011-01-04T20:51:54Z
Indexed on
2011/01/04
20:53 UTC
Read the original article
Hit count: 143
Not quite sure how to ask or define this, but can't figure it out.
I have three tables like this:
persons person_id, first_name, last_name
hobbies hobby_id, name
persons_hobbies person_id, hobby_id
I need to make two lists. Persons that have both hobby A and B, and persons that have hobby A but not B. How can I write these two queries? Can't figure out how to do this with joining and all...
© Stack Overflow or respective owner