View previous topic :: View next topic
|
Author |
Message |
Gops
New User
Joined: 21 Jul 2005 Posts: 23
|
|
|
|
Dear all,
I have two tables as show below,
TAB1 TAB2
empno | name | DEPT | Empno|
101 101
102 102
103 106
104 107
105
Now what is the query to delete the rows from TAB2 which are matching with TAB1?
My ans to this
Delete * form TAB2 wher in
(Select * form TAB1, TAB2
where TAB1.empno=TAB2.empno);
Is this combination of DELETE and SELECT is allowed in DB2?
You early response will apreciated.
Cheers,
Gops |
|
Back to top |
|
|
prabs2006
Active User
Joined: 12 Jan 2006 Posts: 103
|
|
|
|
Hi Gops,
Please check whether this qry works...
Delete from TAB2 B where Exists
(Select A.empno from TAB1 A
where A.empno=B.empno);
Thanks & Regards
Prabs |
|
Back to top |
|
|
nrsmca
New User
Joined: 25 May 2005 Posts: 14
|
|
|
|
Hi,
Try this one....!
Delete from TAB2 A where A.empno in (select B.empno from TAB1 b);
Thanks,
nrsmca |
|
Back to top |
|
|
Gops
New User
Joined: 21 Jul 2005 Posts: 23
|
|
|
|
Thank you very much all of you |
|
Back to top |
|
|
|