Re: like query backslash - Mailing list pgsql-general

From ksherlock@gmail.com
Subject Re: like query backslash
Date
Msg-id 1168817163.955192.295590@a75g2000cwd.googlegroups.com
Whole thread Raw
In response to like query backslash  (Sim Zacks <sim@compulab.co.il>)
List 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 ''


pgsql-general by date:

Previous
From: "Doug Cole"
Date:
Subject: Avoiding empty queries in tsearch
Next
From: Shane Ambler
Date:
Subject: Re: Performance with very large tables