Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE with INNER JOIN Doesn't Work - Pls Help

Status
Not open for further replies.

langnoi

IS-IT--Management
Mar 20, 2003
6
US
I have the following tables and columns:

Table1 with 3 columns: a, b, c

Table2 with 1 column: a

I want to delete the rows from Table1 whenever there is a match of Table1.a = Table2.a.

I tried the following sql but it tries to delete all the rows in Table1 instead of only when there is a match of Table1.a = Table2.a:

delete from table1 where exists (select * from table2 inner join table1 on table2.a=table1.a);

What am I doing wrong?

Please help - thanks!
 
Hi there

Try this:

delete from table1
where table1.a in
(select a from table2);

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top