Page 1 of 1

Left Outer Join More than One column?

Posted: Wed Mar 12, 2014 1:19 am
by pkll
Hi All,

Please let me know whether this left outer join is correct? If correct will it effect the performance because I am using join with more than one columns.
both tables are in database so can I use the SQL join or data stage join. left table contain millions of records.

SELECT a.contractno, b.prism id
FROM Contract
LEFT OUTER JOIN prism
ON a.prism_cont_num = b.prism_cont_num
AND table1.product_cd = b.product_cd
and a.tie_breaker=b.tie_breaker
and a.contract_type=b.contract_type

Posted: Wed Mar 12, 2014 7:19 am
by chulett
How can we say if it is 'correct' or not? Check the explain plan. Run it. Check the results. Then you'll know if it is correct or not.

A join is still a join no matter if it is left, right, inner or outer, regardless of the number of columns you are joining and it will may need indexes on the join columns to perform well. You'll get all contracts with or without matching prism data... as long as you fix your aliases.

Re: Left Outer Join More than One column?

Posted: Wed Mar 12, 2014 3:26 pm
by ssnegi
you would need to define which tables are using the aliases "a", "b", "table1"