join - SQL joining on multiple conditions -


say have query like:

select a.column1, a.column2, b.column3 table1 left join table2 b on (a.column1=b.column3 or a.column2=b.column3) 

is same concatenation of 2 queries:

select a.column1, a.column2, b.column3 table1 left join table2 b on (a.column1=b.column3)  select a.column1, a.column2, b.column3 table1 left join table2 b on (a.column2=b.column3) 

or there differences in final table?

these 2 queries have same result set:

select distinct a.column1, a.column2, b.column3 table1 left join      table2 b      on a.column1 = b.column3 or a.column2 = b.column3; 

and:

select a.column1, a.column2, b.column3 table1 left join      table2 b      on a.column1 = b.column3 union  -- note:  not union select a.column1, a.column2, b.column3 table1 left join      table2 b      on a.column2 = b.column3 ; 

without distinct , union, have sorts of duplicates might arise (or not) between queries.


Comments