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
 

 

Delete from one table based on 2 tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 85
Location: Bangalore

PostPosted: Thu Aug 12, 2010 2:15 am    Post subject: Delete from one table based on 2 tables
Reply with quote

Hi,
Is there a way we can delete from 1 table joining 2 tables.

I know to delete based on joining 1 table as below

Code:
DELETE TABLE1
FROM TABLE1 A
JOIN TABLE 2 B
ON A.COLUMN1 = B.COLUMN1
AND A.COLUMN2 = B.COLUMN2


Now if I want to delete from TABLE1 joining TABLE2 and TABLE3 how do I achieve.

Thanks in advance
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 12, 2010 3:53 am    Post subject:
Reply with quote

Hello,

Needs clarification.

Show some "starting" rows from the tables and what should remain after your process is executed.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Thu Aug 12, 2010 8:23 am    Post subject:
Reply with quote

Huzefa,

You cannot do joins in DELETE statement in DB2.

Try this,
Code:
delete from table1 a
where exists
 (
  select 1 from table2 b
  where a.column1 = b.column1 and a.column2 = b.column2
 )
;


Thanks,
Sushanth
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 Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm


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