Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us