I'm sure I'm missing the correct terminology here, but for this example many-to-many relationship:
A user has many books. A book is owned by many users.
What's the best way to see all books owned by both of two users?
Right now I'm just using this:
SELECT * FROM books
WHERE book_id IN
(SELECT book_id FROM user_has_book WHERE user_id = 'joe' AND book_id IN
(SELECT book_id FROM user_has_book WHERE user_id = 'frank'))
I know that can't be the best way to do this - right? I'm using MySQL