sql - Separation of JOIN and WHERE clauses -
i have written same join 2 different ways:
select one.first, two.second, three.third onetable 1 inner join twotable 2 on one.twokey = two.onekey inner join threetable 3 on two.twokey = three.twokey , one.onekey = three.onekey 1=1 , one.firstnamefield in ('first name', 'second name', 'third name') , two.secondnamefield not in ('last name', 'sirname', 'family name') , three.thirdnamefield = ('nick name', 'pen name', 'handle') and
select one.first, two.second, three.third onetable 1 inner join twotable 2 on one.twokey = two.onekey , one.firstnamefield in ('first name', 'second name', 'third name') , two.secondnamefield not in ('last name', 'sirname', 'family name') inner join threetable 3 on two.twokey = three.twokey , one.onekey = three.onekey , three.thirdnamefield = ('nick name', 'pen name', 'handle') as see, where portion first goes join in re-written query.
is there difference between two?
is 1 more desirable other?
there no difference in results since using inner joins. however, results quite different if these left joins.
i tend put conditions related join in join clause , conditions related overall filtering (a thin distinction i'll grant you) in clause. so, inclination have been first form.
Comments
Post a Comment