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
 

 

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 Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts To know activities on db2 tables ashek15 DB2 4 Fri Mar 03, 2017 11:23 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm


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