Re: like query backslash

From: ksherlock(at)gmail(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Re: like query backslash
Date: 2007-01-14 23:26:03
Message-ID: 1168817163.955192.295590@a75g2000cwd.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Sim Zacks wrote:
> To retrieve the above example, I needed to query:
> select * from filetable where filename like '\\\\\\\\server\\\\dir%'
>
> Is this a bug or is there a reason for this?
>
> Sim

There's a reason. With like queries, if you want to search for the
literal characters % or ? they need to be escaped with a \. So
essentially, the entire string is \ escaped twice. The good news is,
you can redefine the escape character in your query.

eg

select * from filetable where filename like '\\\\server\\dir%' escape ''

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug Cole 2007-01-14 23:41:12 Avoiding empty queries in tsearch
Previous Message Steve Martin 2007-01-14 20:44:06 PQexec does not return.