LIKE clause with \ in PostgreSQL
2 answers
\
doesn't really matter in SQL other than inside a clause for a statement LIKE
, where it can be used to escape wildcard characters.
But you can define another escape character for LIKE, which then makes the character \
"normal":
select 't\om' like '%t\om%' escape '#';
change
As Sunrelax commented, you can also use an empty string as an "escape" sequence:
select 't\om' like '%t\om%' escape '';
+4
source to share
\
is an escape sequence, so you need to escape it too:
select 't\om' like '%t\\om%';
There is also a configuration option that you can set. See Escaping backslashes in Postgresql
+1
source to share