sql server - Is the order of multiple INNER JOIN-s related with the tables relashionship? -
i want join tables using inner join statement.some of them have many many relashionship ,some 1 many , 1 one. want know order of inner join-s statement matters , related type of relashionship(one one,one many etc.)? these 3 codes below output same result?
select .... table1 inner join (table2 inner join table3 on table2.col=table3.col) on table1.col=table2.col select .... table1 inner join (table2 inner join table3 on table2.col=table3.col) on table1.col=table3.col select .... table2 inner join (table1 inner join table3 on table1.col=table3.col) on table3.col=table2.col
select ... table1,table2 (table1.col=table2.col)
exactly order of joins not matter.
better use
select ... table1 inner join table2 on table2.col=table1.col inner join table3 on table3.col=table1.col
yes, inner join's replaced with
where t1.col=t2.col
and sql plan same. if there other filters in condition - mix.
also, if there additional join conditions - better filter out not required records first.
Comments
Post a Comment