I have two tables, let’s call them table1 and table2. They both have a column called ID1 and ID2 which are respective PK for each of two tables.
I have also another table, called table3 which contains ID1 and ID2, establishing a many to many relation between these two tables.
What I need is to get all the records from table2 that are not related with records in table1.
Ex.
- Table 1 contains a record with ID = 1
- Table 2 contains two records with ID 1, 2
- Table 3 contains one record with values 1 – 1
I need a query that will give me as result 2.
Can anyone suggest me a way to proceed?
Thanks
You could also use a LEFT JOIN: