【问题标题】:Search text with and without special characters in a column搜索列中包含和不包含特殊字符的文本
【发布时间】:2021-10-12 11:54:31
【问题描述】:

我正在运行以下查询:

select *
from db.table
where text ilike '%driver needs car%'

我正在返回带有确切给定单词'This cool driver needs car now' 的结果,但如果存在这样的'This cool driver, needs: car now',我还想包含特殊字符。是否也可以搜索这些特殊字符?

【问题讨论】:

    标签: sql impala


    【解决方案1】:

    您可以使用REGEXP_REPLACE 删除所有非字母数字字符。

    select *
    from db.table
    where regexp_replace(text, '[^a-zA-Z0-9]', '') ilike '%driver needs car%'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      • 2020-12-25
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      相关资源
      最近更新 更多