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
 

 

Exclude tables with multiple keys

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Exclude tables with multiple keys
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    Post subject:
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

Site Director


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

PostPosted: Thu Sep 08, 2011 8:06 pm    Post subject:
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    Post subject: Reply to: Exclude tables with multiple keys
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

Site Director


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

PostPosted: Thu Sep 08, 2011 9:08 pm    Post subject:
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    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 Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am
No new posts PA02 - Programmtically control attent... dodithegreat IMS DB/DC 1 Thu Apr 06, 2017 8:33 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm


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