View previous topic :: View next topic
|
Author |
Message |
wineye
New User
Joined: 24 Mar 2005 Posts: 3
|
|
|
|
Please help me on the below query:
1. There are 2 tables T1 & T2 each with columns A1, B1, C1 and A2, B2, C2 respectively.
2. Need to match A1, B1, C1 with A2, B2, C2 respectively. If there is no match between them, then the query needs to fetch the results comparing C1 & C2.
Please let me know if this could be done. If yes, how? |
|
Back to top |
|
|
Santoshdorge
New User
Joined: 27 Jun 2006 Posts: 48 Location: Pune
|
|
|
|
Hi
Try this ...........
select t1.*,t2.*
from t1
,t2
where
a1<> a2
and b1<>b2
and c1 <> c2 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please explain how that query matches the A, B, and C columns. . . What i see refers to "not=" - where is the "match" . . . Then, there is the requirement that if A,B,C do not match, try for a match on C only.
Did you test this before posting it? |
|
Back to top |
|
|
deepak.vl
New User
Joined: 17 Feb 2007 Posts: 38 Location: Hyderabad
|
|
|
|
I think the below query should do (If I understood your question correctly )
SELECT *
FROM T1, T2
WHERE (A1 = A2
AND B1 = B2
AND C1 = C2)
OR ((A1 <> A2
OR B1 <> B2)
AND C1 = C2) |
|
Back to top |
|
|
|