pg中join,left join的使用,将条件放到on和where后面的区别问题

postgresql中left join中将条件放入 on和where的区别。
1.on是肯定会返回左表的数据,所以在on里面的条件都会返回,如果想要过滤数据则需要在where中加条件
2.由于 inner join是两表都有的,所以,返回的结果是和where条件一样的。

示例:
select * form tab1 left join tab2 on (tab1.size = tab2.size) where tab2.name=’AAA’
select * form tab1 left join tab2 on (tab1.size = tab2.size and tab2.name=’AAA’)

原文地址:https://www.cnblogs.com/zhangfx01/p/14872368.html