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

to fetch unmatched rows from two tables


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

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Oct 21, 2008 8:01 pm
Reply with quote

Hi,

I want to fetch unmatched rows from two tables. I have a common key which should not be equal.
In other words, I want all the rows other than those which I would get from an inner join on the common key.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Oct 21, 2008 8:14 pm
Reply with quote

Ex.

cost
prod-num cost seq-id
1 3 2
2 2 5
3 2 7
4 3 3

PRICE
prod-num price seq-id
1 1 2
2 2 4
3 3 6
4 4 3


Code:
SELECT * FROM COST A,PRICE B
WHERE A.PROD-NUM=B.PROD-NUM
  AND A.SEQ-ID =B.SEQ-ID


OUTPUT
prod-num cost seq-id prod-num price seq-id
1 3 2 1 1 2
4 3 3 4 4 3

my requirement is,

OUTPUT
prod-num cost seq-id prod-num price seq-id
--------------------------- 2 2 4
2 2 5 ---------------------------
--------------------------- 3 3 6
3 2 7 --------------------------
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Wed Oct 22, 2008 10:35 am
Reply with quote

I think my requirement will be satisfied by exceptional join or by coding a NOT EXISTS clause on second table.
Can someone put more light on these?
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top