【问题标题】:Select rows where jsonb array contains any string in array选择 jsonb 数组包含数组中任何字符串的行
【发布时间】:2015-10-23 19:34:47
【问题描述】:

这是我目前的 SQL:

select * from table where table.json_info @> '{"search_tags":["hello", "world"]}'

如果该行在search_tags 中同时具有helloworld,则此方法有效

我想知道是否有一种方法可以包含具有 helloworld 的行,当然还有两者兼有的行。

提前感谢大家!

【问题讨论】:

  • select * from table where table.json_info @> '{"search_tags":["hello"]}' or '{"search_tags":[ "world"]}'

标签: sql arrays postgresql select jsonb


【解决方案1】:

感谢@utility 让我在这里走上正轨。

这就是我的结局:

select * from table where table.json_info @> '{"search_tags":["hello"]}' or table.json_info @> '{"search_tags":[ "world"]}'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-28
    • 2011-01-08
    • 2022-08-19
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 2015-09-08
    相关资源
    最近更新 更多