Escaping string for LIKE

Поиск
Список
Период
Сортировка
От David Sheldon
Тема Escaping string for LIKE
Дата
Msg-id 4CEBA649.4020202@we7.com
обсуждение исходный текст
Ответы Re: Escaping string for LIKE
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Matthew Walden
Дата:
Сообщение: Re: postmaster.pid does not exist. cannot start postgres server on ubuntu
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Fwd: Postgres forums ... take 2