In general, there are 2 tables that I want to join by 2 fields.
Request example:
SELECT * FROM T1 LEFT JOIN T2 ON T1.F=T2.F AND T1.F2=T2.F2 WHERE T2.ID IS NULL So, this request returns nothing to me at all, although there are such records.
By scientific method, I came to the conclusion that this is due to the fact that the fields by which I make the connection can be NULL .
If I rewrite the query like this:
SELECT * FROM T1 LEFT JOIN (SELECT * FROM T2 WHERE T2.F1 IS NOT NULL AND T2.F2 IS NOT NULL) AS T2 ON T1.F=T2.F AND T1.F2=T2.F2 WHERE T2.ID IS NULL That returns the expected result. Prompt, it should work this way, or can the first query be rewritten without a subquery, so that everything is clear?