Re: Escape string for LIKE op

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: Escape string for LIKE op
Дата
Msg-id 520D4CEC.3070300@dalibo.com
обсуждение исходный текст
Ответ на Escape string for LIKE op  (Robert James <srobertjames@gmail.com>)
Список pgsql-general
On 08/15/2013 10:16 PM, Robert James wrote:
> How can I escape a string for LIKE operations?
>
> I want to do:
>
> SELECT * FROM t WHERE a LIKE b || '%'
>
> But I want be to interpreted literally.  If b is 'The 7% Solution', I
> don't want that '%' to be wildcard.  I can't find an appropriate
> function to escape it and any other potential wildcards for LIKE
> clauses.

In this particular case, you're better off changing the query to be

SELECT * FROM t WHERE a >= b;

but if your needs are more complex than your actual question, you'll
most likely need to process b like Jeff explained.
--
Vik


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Strange result with "SELECT ... ORDER BY random() LIMIT 1" and JOINs
Следующее
От: bricklen
Дата:
Сообщение: Re: devide and summarize sql result (all)