MySQL: List rows who have one but not another many-to-many relationship
- by Svish
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...