arrays - PostgreSQL 选择一个数组中不存在于另一个数组中的项目

标签 arrays postgresql

具有两个整数数组列的 PostgreSQL 表,例如 a = [1,2,3,4]b = [1,2,3,4,5,6]b 中不在 a 中的项是 5,6,因此作为查询结果我想要一个数组 [5, 6].

如何在 PostgreSQL 中实现这一点?

最佳答案

安装了intarray扩展后,可以简单地选择a-b,cp。 https://www.postgresql.org/docs/current/static/intarray.html

关于arrays - PostgreSQL 选择一个数组中不存在于另一个数组中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47800387/

相关文章:

javascript - 将数组转换为字符串 Javascript

c - 为什么此函数无法成功确定两个任意字符串是否相同?

postgresql - 是否有与 MSSQL FILESTREAM 存储等效的 PostgreSQL?

sql - 链接服务器(从postgresql中读取数据并插入到SQL Server中)

javascript - 仅显示数组中的一项

python - 使用 numpy 数组和元组保持每个元素出现一次的快速方法

node.js - AWS lambda 中的 pg-promise

postgresql - 有没有办法配置 sonar-maven-plugin 以通过 REST API 存储报告

postgresql - bugzilla 无法连接到 postgres 服务器

javascript - array[id].method 不起作用?