mysql内外连接时,on跟where的区别


写sql的时候经常遇到各种连接查询,left joinright joininner join,做个笔记

外连接(left join、right join)

left join...on...and...where...and...

on...and...

是对右表中的数据进行筛选,返回的是左表中的所有记录

where...and...

是对on之后的记录进行筛选

inner join

inner join...on...and...where...and...

on...and...

是对两表中的数据进行筛选,返回的是两表中的所匹配的记录

where...and...

是对on之后的的记录进行筛选


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM