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!

delete query with composite primary key

PleiadianJan 18 2010 — edited Jan 18 2010
I have the following problem, which sounds painfully simple but I am a bit at a loss :)

I have a table T1 with composite primary key F1 and F2.

There's a second table T2 that I want to use to delete records from T1. It als contains F1 and F2.

I want to do something like this
delete from T1
where T1.F1, T1.F2 in (select T2.F1, T2.F2 from T2);
Obviously, this does not work.

There are some solutions, but I find them not satisfying:
- A PL/SQL Loop and pass the key one by one
- Concatenate F1 and F2: where T1.F1 || T1.F2 in (select T2.F1 || T2.F2 from T2); -- but this is very ugly.

Surely this must be possible in one simple SQL statement...

Thanks!

Rob
This post has been answered by 730428 on Jan 18 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2010
Added on Jan 18 2010
2 comments
3,560 views