I have an ownership relation between two tables,
say users(int user_id) and user_books(int user_book_id,int user_id,int book_id)
and two additional tables books(int book_id, varchar book_title, int author_id) and authors (int author_id, varchar author_name).
Given a specific user_id I want to get the books that the user DOES NOT HAVE that where written by authors that he does have other books writen by them.
So if the user has BOOK1 (i.e. there exists a row for this in user_books) and does not have BOOK2 and BOOK3 that where written by the same author as BOOK1, I want to get the ids for BOOK2 and BOOK3.
I guess I can do this using a SELECT WHERE NOT IN () but for performance reasons I am looking for a join based solution.