I have two tables that I’m currently joining on three fields:
SELECT t1.A, t1.B, t1.C, t2.D
FROM t1, t2
WHERE t1.A = t2.A
AND t1.B = t2.B
AND t1.C = t2.C
Because of the way my data works, if the join does not match up on A/B/C, then I want to join on A/B. If that join does not match up, then I just want to join on A. Is this type of cascading join possible within a SQL query (I’m using Oracle 10g)? Or do I have to handle this with code?
Would this work for you?
EDIT:
If you wanted all the results but wanted to see how they were matched then you could issue this:
In the resultset you could see what level of matching the rows had and then use the data from there.
Perhaps by wrapping this query in an outer query you could either discard the rows you didn’t want or prioritise the ones you do want.
Hope it helps…