BUG #1454: error in "select * from table where a1 like '%\%%' " ???

Поиск
Список
Период
Сортировка
Искать

BUG #1454: error in "select * from table where a1 like '%\%%' " ???

От:
"Ricky" <ricky@ez2.us>
Дата:
The following bug has been logged online:

Bug reference:      1454
Logged by:          Ricky
Email address:      ricky@ez2.us
PostgreSQL version: 8.0
Operating system:   Mandrake Linux 10.1
Description:        error in "select * from table where a1 like '%\%%' " ???
Details: 

I perform a query to get data,which contains '%'.
so I do this query.
select * from table where a1 like '%\%%';
but it returns all rows.
then I do another query.
select * from table where a1 like '\%';
but it still return all rows.
like "select * from table"

Re: BUG #1454: error in "select * from table where a1 like '%\%%' " ???

От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Ricky wrote:
> I perform a query to get data,which contains '%'.
> so I do this query.
> select * from table where a1 like '%\%%';
> but it returns all rows.

select * from table where a1 like '%\\%%';

The first \ escapes the second \ for the string parser, the second \ is 
the escape character for the LIKE pattern.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/
FAQ