View previous topic :: View next topic
|
Author |
Message |
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
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 |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
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 |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
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 |
|
|
|