mysql - Priority executing WHERE clause in JOIN keyword -
i want know, when use where
clause following directives join
, happen ?
in fact, want know priority of execute. instance, consider below code:
select * tablename1 t1 inner join tablename2 t2 on t1.id=t2.id id='10'
then happen in above code first?
sql select rows id
10 , runs join
keyword ? or join
keyword runs in first , where
clause?
to answer question join runs first, if want filter try query
select * ( select * tablename1 id='10') t1, ( select * tablename2 id = '10' ) t2
update: others suggest checking execution plan understand how query performs, still if want decide on own, better yourself.
update 2: @giorginakeuri points. mentioned in comments after change inner queries inner join not needed. simple cartesian join enough.
read art of sql more info on sql optimisations.
for more advanced knowledge try sql tuning
Comments
Post a Comment