Skip to content
Advertisement

How can I query with NOT IN in a many-to-many relationship including NULLs

Given I have 3 tables and I need to retrieve all the rows where there is no relationship with a specific record and include the rows where there are zero relationships, how can I build this query?

I need all books where the author Dewey (id = A2) has no relation at all.

Because B4 has a relation with author Dewey (A2), it should not be returned.

The query should return only B1 and B2.

Advertisement

Answer

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement