【问题标题】:SQL bigint array column contain any member of another array?SQL bigint 数组列包含另一个数组的任何成员?
【发布时间】:2021-01-24 23:30:40
【问题描述】:

在我的架构中,我的 supply_source 为 bigint[]

我想查询 mytable 中所有在其 supply_sources 中有 123 或 456 的行。

当我使用这个查询时,我只得到 123 和 456 作为其供应源的行。

SELECT * 
FROM mytable  
WHERE supply_source = ARRAY[123, 456]::bigint[]
LIMIT 10;

我应该如何修改我的查询?

【问题讨论】:

  • 选择合适的数据库。
  • 我删除了mysql标签,因为MySQL没有数组数据类型。

标签: sql arrays postgresql where-clause


【解决方案1】:

可以使用数组重叠运算符&&:

WHERE supply_source && ARRAY[123, 456]::bigint[]

【讨论】:

    猜你喜欢
    • 2023-03-07
    • 2011-01-16
    • 1970-01-01
    • 2022-01-09
    • 2018-12-20
    • 2013-05-06
    • 2019-09-03
    • 2020-01-28
    • 2023-03-08
    相关资源
    最近更新 更多