r5d4 - Wednesday, December 13, 2017 10:26 AM
You could use 2 LEFT JOINS and then determine which one of the 2 values you want to keep using COALESCE.
SELECT ...
, COALESCE(t2.col2, t3.col2) AS col2
, COALESCE(t2.col3, t3.col3) AS col3
, COALESCE(t2.col4, t3.col4) AS col4
FROM table1 t
LEFT JOIN table2 t2 ON t2.col1 = t.col1
LEFT JOIN table2 t3 ON t3.text1 = t.text1
You cannot utilize a UNION ALL - it would have to be a UNION which will require a sort operation to remove duplicates.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs