SQL参数放在where前后的区别

本博客记录一个细节,在使用sql left join时候,参数放在left join后面当条件,还是放在where后的区别

给出两条SQL
tt.book_type神祇领主时代 = 'TIPS_TYPE',放数据库软件在left join后面当条件

select tc.seq,
tc.tips_flag,
tc.is_valid,
tc.create_time,
tt.book_name tipsType
from t_tips_config tc
left join t_book tt
on tt.book_code = tc.tips_flag
and tt.book_type = 'TIPS_TYPE'

tt.book_type = 'TIPS_TYPE',放在whsqlserver面试题ere后面当条件

select tc.seq,
tc.tips_flag,
tc.is_valid,
tc.create_time,
tt.book_name tipsType
from t_tips_config tc
left join t_book tt
on tt.book_code = tc.tips_flag
where tt.book_type = 'TIPS_TYPE'

这两种情况意义完全不一样的,前者如果t_book没有book_type = 'TIPS_TYPE'的数据,整条SQL还是可以查到数据的,只是t_book的参数孙侨潞没查到而已,后者,一旦出现book_type = 'TIPS_苏卿陆容渊TYPE'没有数据,那就整条SQL都查不sqlserver怎么读到数据,这样是不合理的,因为业务需要查出t_tips_confisqlserver默认端口g的表,不然就不会用左连接了

这是一个小细节,记录一下