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
 
to fetch unmatched rows from two tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: to fetch unmatched rows from two tables
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    Post subject:
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    Post subject:
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    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 To get Non matching row after compari... vinu78 DB2 7 Fri Jan 05, 2018 5:43 pm
No new posts DB2 catalog tables Pavan kumar chauhan DB2 8 Thu Dec 21, 2017 6:32 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Can we combine the rows with same key... V S Amarendra Reddy DB2 12 Fri Dec 01, 2017 10:29 pm

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