mysql内外连接时,on跟where的区别 外连接(left join、right join) inner join

写sql的时候经常遇到各种连接查询,left joinright joininner 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之后的的记录进行筛选