小编Pat*_*nio的帖子

从列表中查找表中不存在的 ID

假设我有以下架构和数据:

create table images(
  id int not null
);

insert into images values(1), (2), (3), (4), (6), (8);
Run Code Online (Sandbox Code Playgroud)

我想执行如下查询:

select id from images where id not exists in(4, 5, 6);
Run Code Online (Sandbox Code Playgroud)

但这不起作用。上面的情况应该返回5,因为它不存在于表记录中。

postgresql if-not-exists

33
推荐指数
3
解决办法
6万
查看次数

标签 统计

if-not-exists ×1

postgresql ×1