Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Deleting matchnig rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Deleting matchnig rows
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    Post subject:
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    Post subject:
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    Post subject: Re: Deleting matchnig rows
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Can we use OPTIMIZE FOR 1 ROWS for fe... cvijay784 DB2 1 Fri Aug 05, 2016 11:56 am
No new posts Column into multiple rows V S Amarendra Reddy SYNCSORT 2 Thu Mar 03, 2016 8:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us