I'm A SQL newbee looking for advice on a query:
(Oracle 11g R2)
I'm trying to delete all records from TABLE_A when the string in COLUMN_1 or COLUMN_2 doesn't match the string in COLUMN_1 of TABLE_B.
In other words, if either of the values from TABLE_A match, I DO NOT want to delete that record.
Additionally, if COLUMN_3 of TABLE_A is flagged ('X'), don't delete that record under any circumstances.
The query I have looks like this but does not produce the correct result:
DELETE FROM TABLE_A WHERE COLUMN_3 != 'X'
AND COLUMN_1 NOT IN (SELECT COLUMN_1 FROM TABLE_B)
AND COLUMN_2 NOT IN (SELECT COLUMN_1 FROM TABLE_B);
Thanks in advance for your assistance.