If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Adding books, or authors is working as expected, so is selecting a list of books with their authors. However In the part where I want to be able to delete books and authors, I'm having a problem.. I want to after say deleting author X, do you also want to delete the books by that author? But I want to list the book AND any other authors associated with the book (that way if you delete author x but author y helped with a book maybe you don't want to delete that book. The problem I'm having is selecting the books written by author x, along with all authors associated with that book.

Its obviously easy to find the books by the author
select * from reading_rel JOIN reading_books on books_id=id_book WHERE author_id=$id
What I'm having a problem with is also selecting the other authors... Any help would be greatly appreciated... If i have to resort to multiple queries that would make me sad but I'll do it. Thanks in advance.

SELECT b.*,a.* FROM reading_rel
JOIN reading_books as b ON b.id_book = reading_rel.book_id
JOIN reading_authors as a ON a.id_author = reading_rel.author_id
WHERE reading_rel.book_id IN
(SELECT book_id FROM reading_rel
WHERE author_id = $id)