IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Deleting matchnig rows


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gops

New User


Joined: 21 Jul 2005
Posts: 23

PostPosted: Mon Jan 23, 2006 12:12 pm
Reply with quote

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
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Jan 23, 2006 12:24 pm
Reply with quote

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
View user's profile Send private message
nrsmca

New User


Joined: 25 May 2005
Posts: 14

PostPosted: Tue Jan 31, 2006 4:46 pm
Reply with quote

Hi,

Try this one....!

Delete from TAB2 A where A.empno in (select B.empno from TAB1 b);

Thanks,
nrsmca
Back to top
View user's profile Send private message
Gops

New User


Joined: 21 Jul 2005
Posts: 23

PostPosted: Tue Jan 31, 2006 5:01 pm
Reply with quote

Thank you very much all of you
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Deleting a Tape file JCL & VSAM 14
No new posts CA7 deleting files in steps after job... CA Products 4
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top