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
 
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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm

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