Netezza LIKE operator not finding subsequent backslashes
-
11-12-2019 - |
Question
Netezza is able to find records when using the LIKE operator when the first character contains a backslash character. But when subsequent characters contain a backslash character, it cannot. How can I correct this?
Result set has records:
SELECT * FROM TABLENAME WHERE PATH LIKE '\some_path%'
Result set has 0 records:
SELECT * FROM TABLENAME WHERE PATH LIKE '\some_path\%'
Solution
I had to avoid the escape character in the pattern matching string (after the LIKE), and append ESCAPE ''
to avoid using the backslash as an escape character. In this example, I had _
characters in the literals, as well as \
characters.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange