November 22, 2009 at 10:13 pm
I have written a left outer join and in the ON CLAUSE I have used an OR CONDITION also
select *
from table A
left outer join table B on (table A.col1 = tableB.col1 OR table.col1 IS NULL) AND
(table A.col2 = tableB.col2)
The use of OR has seriously hampered the preformance.
Is there an alternative to obtain the same objective differently.
my solution -
i was planning to split the query using 'UNION ALL' and perform left outer join two times
select *
from table A
left outer join table B on (table A.col1 = tableB.col1 AND table A.col2 = tableB.col2)
UNION ALL
select *
from table A
left outer join table B on (table B IS NULL AND table.col1 IS NULL)
November 23, 2009 at 8:28 am
Using UNION ALL is certainly a step in the right direction. Without having a better understanding of the structures and data it is hard, at least for me, to go beyond that.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply