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

Exclude tables with multiple keys


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

New User


Joined: 29 Jun 2010
Posts: 6
Location: Chennai

PostPosted: Wed Sep 07, 2011 7:35 pm
Reply with quote

Hi,

I have 2 tables. Both the tables have common column names. I want to exclude the records which match between these tables.

Example :
Table 1 : Columns Col-1,Col-2,Col-3,Col-4
Table 2 : Columns Col-1,Col-2,Col-3
I want to select only those records from Table-1 where the combination of (Col-1,Col-2,Col-3) is not in Table-2.

How can this be achieved? I am able to do it with Union. Can i do it without union?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Sep 08, 2011 12:48 pm
Reply with quote

union ? wow, i have no idea on how you would do that.

How about where not exists() or EXCEPT
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 Sep 08, 2011 8:06 pm
Reply with quote

Hello,

How many rows are there in these tables?

Is the combination of col1-2-3 a key in each table?
Back to top
View user's profile Send private message
Karthikeyan Venkatadri

New User


Joined: 29 Jun 2010
Posts: 6
Location: Chennai

PostPosted: Thu Sep 08, 2011 8:10 pm
Reply with quote

Hi,

There are around 15000 rows in Table-1 and Table-2 can have the same amount of data.

Yes, the columns are keys in both the tables.
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 Sep 08, 2011 9:08 pm
Reply with quote

Hello,

Quote:
Yes, the columns are keys in both the tables.
Just to be clear - are all 3 columns part of a single key? This would be different that each column being a separate key.

Regardless, one easy to do what you want is to unload both tables into sequential files and then using your sort product, JOIN the 2 sequential file, keeping what you want and discarding the rest. . .
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
Search our Forums:

Back to Top