View previous topic :: View next topic
|
Author |
Message |
Karthikeyan Venkatadri
New User
Joined: 29 Jun 2010 Posts: 6 Location: Chennai
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
union ? wow, i have no idea on how you would do that.
How about where not exists() or EXCEPT |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How many rows are there in these tables?
Is the combination of col1-2-3 a key in each table? |
|
Back to top |
|
|
Karthikeyan Venkatadri
New User
Joined: 29 Jun 2010 Posts: 6 Location: Chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|