Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

SQL 'Not In'

503828Jun 2 2014 — edited Jun 3 2014

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.

Alex

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2014
Added on Jun 2 2014
10 comments
205 views