Re: how to escape _ in select

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: how to escape _ in select
Дата
Msg-id i2r9ss$gt0$1@dough.gmane.org
обсуждение исходный текст
Ответ на how to escape _ in select  (Wes James <comptekki@gmail.com>)
Список pgsql-sql
Wes James, 28.07.2010 19:35:
> I'm trying to do this:
>
> select * from table where field::text ilike '%\_%';
>
> but it doesn't work.
>
> How do you escape the _ and $ chars?
>
> The docs say to use \, but that isn't working.
>
> ( http://www.postgresql.org/docs/8.3/static/functions-matching.html )
>
> The text between '%...%' can be longer, I'm just trying to figure out
> how to escape some things.  I've found that ' works with '' and \
> works with \\
>

To get around the somewhat quirky usage of backslashes, you can simply define a different esacpe character:

select *
from table
where field::text ilike '%@_%' escape '@';

Thomas




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

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: how to escape _ in select
Следующее
От: Rainer Stengele
Дата:
Сообщение: Re: grouping subsets