table a(id, type):
id type 
----------------------------------
1 1 
2 1 
3 2 
table b(id, class):
id class 
---------------------------------
1 1
2 2
sql
语句1:select a.*, b.* from a left join b on a.id = b.id and a.type = 1;
sql语句2:select a.*, b.* from a left join b on a.id = b.id where a.type = 1;
sql语句3:select a.*, b.* from a left join b on a.id = b.id and b.class = 1;
sql语句1的执行结果为:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 2 2
3 2 
sql语句2的执行结果为:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 2 2
sql语句3的执行结果为:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 
3 2 
由sql语句1可见,left join 中左表的全部记录将全部被查询显示,on 后面and a.type = 1没起作用,看到第3行“3 2”存在,并没有过滤掉type =2的结果;由sql语句3可见,on后面的条件中,右表的限制条件将会起作用。