「MySQL笔记」left join-on-and 与 left join-on-where 的区别( 二 )

  • 写法 left-join-on-where 在连表查询过程中先根据 on 条件过滤右表 , 再执行 join 操作生成临时表 , 然后对临时表执行 where 条件, 因此 , on-where 写法会先对右表做1个条件的过滤 , 然后对 join 后的结果再执行1个条件的过滤
  • 由于 on 优先级比 where 更高 , 执行时机会更早 , 因此 , 理论上来说 on-and 写法比 on-where 写法效率更高、执行更快
  • 参考资料
    1. MySQL left join操作中on和where放置条件的区别介绍
    2. MYSQL 表左连接 ON AND 和ON WHERE 的区别




    推荐阅读