Athena/Presto 转义下划线

Athena/Presto Escape Underscore

我试图转义 like 运算符中的下划线,但没有得到任何结果。我正在尝试查找值类似于 'aa_'.

的任何行

WHERE value LIKE '%aa\_%'

使用ESCAPE:

Wildcard characters can be escaped using the single character specified for the ESCAPE parameter.

WITH dataset (str) AS (
    VALUES ('aa_1'),
        ('aa_2'),
        ('aa1')
)
SELECT *
FROM dataset 
WHERE str like 'aa\_%' ESCAPE '\'

输出:

str
aa_1
aa_2