Netezza LIKE Operator Issue with Backslashes

character-setlikenetezza

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\%'

Best Answer

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.