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

Delete from one table based on 2 tables


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

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Thu Aug 12, 2010 2:15 am
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

Moderator Emeritus


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

PostPosted: Thu Aug 12, 2010 3:53 am
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: 1020
Location: India

PostPosted: Thu Aug 12, 2010 8:23 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top