database - 将列与postgressql中的文本数组进行比较
问题描述
我们有一个 PostgreSQL 数据库,其中我有两个列 text[] 数据类型的表。当我使用内部联接获取详细信息时,我看不到它与任何行匹配。例如
create table test{
names text[],
id
}
create table test_b{
names text[],
id
}
现在当我在查询下运行时,
SELECT t.* from test t inner join test_b tt
其中 t.names=tt.names; 我没有看到任何结果。我什至尝试过正常查询
SELECT * FROM test where names='{/test/test}';
它也没有工作。有什么建议么?
解决方案
我怀疑你想要数组重叠运算符&&
。此外,由于您不需要从 中返回任何内容test_b
,因此与相关子查询一起使用exists
比 a 更相关join
:
select t.*
from test t
where exists (select 1 from test_b b where t.names && b.names)
推荐阅读
- apache-spark - spark 3.1.2 与 3.0.2 的显着变化是什么导致磁盘空间已用,而有足够的内存可用
- flutter - Flutter web 'minified:eU 实例
' - docker - CD 命令在 ubuntu 框中的 docker 容器内不起作用:18.04(vagrant)
- c - 共享内存中变量的最小可能值
- django - 我是 Django 的新手,一直被困在 ERROR 404 (Page Not Found)
- boolean-logic - Python真值表
- linux - 通过保存虚拟设备删除 genymotion
- dart - 飞镖中的异步等待同步运行?
- jquery - 指定何时应该使用 $(window).load 而不是 $(document).ready?jQuery
- javascript - 如何过滤其中包含空格的 Shopify 产品类型?