一、表结构
postgres=# \d a
Table "public.a"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
v | text | | |
Indexes:
"a_pkey" PRIMARY KEY, btree (id)
postgres=#
postgres=#
postgres=#
postgres=# \d b
Table "public.b"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
v | text | | |
Indexes:
"b_pkey" PRIMARY KEY, btree (id)
二、两条SQL语句
-- 语句一
select a.id, a.v from a left join b on a.id = b.id and b.v = 'a' where b.id is null;
-- 语句二
select a.id, a.v from a where NOT E