他们不一样。请参阅@Pavel_Veller 提供的答案这只是为了支持他的答案。在 Postgres 上运行:
create table tb1( tb1_id int );
create table tb2( tb1_id int, uid int );
insert into tb1 values( 1 );
insert into tb2 values( 1, 0 );
select a.tb1_id
from tb1 a left join tb2 b on a.tb1_id = b.tb1_id and b.uid = 3
where a.tb1_id = 1;
select a.tb1_id
from tb1 a left join tb2 b on a.tb1_id = b.tb1_id
where a.tb1_id = 1
and b.uid = 3;
结果:
postgres=# select a.tb1_id
postgres-# from tb1 a left join tb2 b on a.tb1_id = b.tb1_id and b.uid = 3
postgres-# where a.tb1_id = 1;
tb1_id
--------
1
(1 row)
postgres=# select a.tb1_id
postgres-# from tb1 a left join tb2 b on a.tb1_id = b.tb1_id
postgres-# where a.tb1_id = 1
postgres-# and b.uid = 3;
tb1_id
--------
(0 rows)