I am trying to select a record out of the table1 by joining table2 and using table2 columns in the WHERE statement. Col1 and Col2 in table1 can be stored in col1 of table2. I need to join col1 of table2 with either the value of col1 or col2 in table1
here is the sql statement I created so (pseudo):
SELECT t1.Col1, t1.Col2, t1.Col3, t1.Col4 FROM table1 t1 JOIN table2 t2 on t2.Col1 = t1.Col1 or t2.Col1 = t1.Col2
What would be the best way to approach this?
That should be fine. Another way to write the same condition is as follows:
It shouldn’t matter which way you do it in this case. Do what you find more readable.