I am having some bother in selecting books that are neither translated books, books series' nor book sections. The structure looks like this. (sorry, stackoverflow won't let me post an image with less than 10 reputation)
It uses class inheritance design pattern with shared primary keys.
This is what I've came up with so far:
SELECT * FROM ( ( (`hedwig_db`.`refs` JOIN `hedwig_db`.`books` ON `refs`.`ref_id`=`books`.`ref_id` ) LEFT JOIN `hedwig_db`.`authors` ON `refs`.`ref_id` = `authors`.`ref_id` ) LEFT JOIN `hedwig_db`.`editors` ON `books`.`book_id`=`editors`.`book_id` ) WHERE `books`.`book_id` NOT IN (SELECT `books`.`ref_id`, `books`.`book_id`, `book_section`.`book_id`, `book_translated`.`book_id`, `book_series`.`book_id` FROM( ( (`hedwig_db`.`books` JOIN `hedwig_db`.`book_translated` ON `books`.`book_id`=`book_translated`.`book_id` ) JOIN `hedwig_db`.`book_section` ON `books`.`book_id`=`book_section`.`book_id` ) JOIN `hedwig_db`.`book_series` ON `books`.`book_id`=`book_series`.`book_id` ) )
It's the NOT IN query that is returning nothing and I can't for the life of me figure out how to get what I'm looking for! Thanks in advance :)