它們是不一樣的。查看@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)