Apologies if this has been asked before, searching for it yields too many results.
I've been eliminating NOT EXISTS in some code by LEFT JOINing tableX and using a WHERE TableX.JoinColumn IS NULL
Big gains, I'm pleased with that.
My next challenge is OR in a JOIN criteria, so...
SELECT id
FROM table1
LEFT JOIN table2
ON table1.keycolumn = table2.keycolumn
AND (table1.code1 = table2.code1 OR table1.text1 = table2.text1)
Performing 2 SELECT queries and UNIONing them to avoid the OR comes to mind,
The bigger picture is that I want to LEFT JOIN to this subquery to reproduce the NOT EXISTS functionality that performs so badly.
I'm eliminating records that match the crazy OR join.
This is a medical application, I can't change the tables, merely report on them.
Any ideas most appreciated.
Thank you