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

Started by Rickyabout 21 years ago2 messagesbugs
Jump to latest
#1Ricky
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"

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Ricky (#1)
Re: BUG #1454: error in "select * from table where a1 like '%\%%' " ???

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/