Search Postgresql Archives

Escaping string for LIKE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I have a string, and I want to search for everything that starts with that string then I could do:

SELECT * FROM users WHERE name LIKE string || '%';

Now, if string contains \, _ or % then it won't do what I expect.

Is there a built-in function that I can call to escape the string so that it isn't special for LIKE, or is it a case of regexing and putting a \ before each \, _ or %?

David

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux