Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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
414 views