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

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Ricky" <ricky(at)ez2(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1454: error in "select * from table where a1 like '%\%%' " ???
Date: 2005-02-03 06:55:16
Message-ID: 200502030755.16452.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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/

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2005-02-03 06:55:51 Re: BUG #1457: ./configure --with-openssl --enabled-thread-safety fails
Previous Message Tom Lane 2005-02-03 06:02:01 Re: BUG #1455: pg_dumpall fails