Escaping the underscore in a like statement results in no records being matched.
Example:
select * from mytable where category like '%\_common';
Will not match any results. Without the \, it will match _uncommon.
Escaping doesn't appear to be working properly.
Presto follows ANSI SQL for the LIKE operator: you must specify the escape character using the ESCAPE clause. There is no default as in some other databases.
'abc' LIKE 'a\_c' ESCAPE '\'
How can I input a quote? I try ' ' to escape, but failed.
select '\'' ESCAPE '\' from test
@hellopower in standard SQL, single quotes are escaped by doubling them: SELECT 'it''s great'
Why is there no documentation within presto's SQL doc about LIKE?
This page mentions it, but that's it. https://prestodb.io/docs/current/functions/regexp.html
Can this comment be moved to a new issue?
We should document it here: https://prestodb.io/docs/current/functions/comparison.html
It's been 2.5 years plus and no movement on documenting LIKE and the wildcards it uses...
@oaustegard do you want to submit a PR?
Might have to - meanwhile found the Test cases for the LIKE syntax - so that helps: https://github.com/prestodb/presto/blob/9aa8f80edf946d26760012d9da4c1b34cff25eb7/presto-main/src/test/java/com/facebook/presto/sql/TestExpressionInterpreter.java#L1223
Most helpful comment
We should document it here: https://prestodb.io/docs/current/functions/comparison.html