时间:2021-07-01 10:21:17 帮助过:4人阅读
2.where是全部连接完后,对临时表进行筛选,筛选对左表和右表都有效
在使用inner join时,on and与on where条件的区别:不管是对左表还是右表进行筛选,on and和on where都会对生成的临时表进行过滤。
1. 新建表 t1
2. 新建表 t2
3. 关联查询:
select * from t1 left join t2 on t1.user_id = t2.user_id
a.) 对左表加and 条件
select * from t1 left join t2 on t1.user_id = t2.user_id and t1.deleted = 0
b.) 对右表加and 条件
select * from t1 left join t2 on t1.user_id = t2.user_id and t2.deleted = 0
select * from t1 left join t2 on t1.user_id = t2.user_id where t1.deleted = 0
select * from t1 left join t2 on t1.user_id = t2.user_id where t2.deleted = 0
SQL on and 和 on where 的区别
标签:str ted 临时 code col sele 记录 select har