in reply to Many-to-many relationships in databases : SOLVED
This is really off-topic for this site, but let's have a go anyway.
You need to join the BookAuthor table with itself. I'm old-skool so I do joins in the WHERE clause, but there's probably a simpler way to do it using an explicit JOIN clause.
select a.book from BookAuthor a, BookAuthor b where a.author = 'Smith' and b.author = 'Jones' and a.book = b.book;
Update: The JOIN syntax looks like this:
select a.book from BookAuthor a inner join BookAuthor b on a.book = b.book where a.author = 'Smith' and b.author = 'Jones';
You should be able to omit the "INNER", but I was testing on a rather old version of MySQL which didn't support the abbreviated syntax.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
---|