Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我的表中的一列是一个数组,我想检查该列是否包含包含子字符串“denied”的元素(因此“denied at 12:00 pm”、“denied by admin”等元素都将计算在内,我相信我将不得不使用“喜欢”来识别模式)。如何为此编写sql?
使用 presto 的数组函数:
filter()
cardinality()
像这样:
where cardinality(filter(myArray, x -> x like '%denied%')) > 0
在较新版本的 PrestoSQL(现在称为Trino )中,您可以使用以下any_match函数:
any_match
WHERE any_match(column, e -> e like '%denied%')
在此处查看数组运算符文档
contains(array_column,'denied')