【问题标题】:Athena/Presto Split string for In Query用于 In Query 的 Athena/Presto 拆分字符串
【发布时间】:2021-05-07 11:35:03
【问题描述】:

IN 查询是否可以使用逗号分隔的字符串?

我想使用字符串a,b,c执行以下查询

select * from tablename where colname in ('a', 'b', 'c')

示例 - select * from tablename where colname in (split_string('a,b,c'))

【问题讨论】:

    标签: sql arrays split presto amazon-athena


    【解决方案1】:

    您可以使用split(string,delimiter) 分割字符串和布尔函数contains(array, element) 来检查数组是否包含值:

     select * from tablename where contains(split('a,b,c',','),colname)
    

    【讨论】:

      猜你喜欢
      • 2020-02-14
      • 2021-02-02
      • 2021-06-16
      • 2019-05-13
      • 2018-10-06
      • 2022-06-21
      • 1970-01-01
      • 2020-02-14
      • 2019-07-29
      相关资源
      最近更新 更多