Skip site navigation (1) Skip section navigation (2)

Using backslash in query

From: Michael Brusser <michael(at)synchronicity(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Using backslash in query
Date: 2003-10-03 13:40:50
Message-ID: (view raw or whole thread)
Lists: pgsql-hackers
I'm afraid I'm confused about something very simple... but anyway

I need to run a query on a varchar field containing a backslash.
My first attempt looked like this:
  SELECT smth. FROM  tbl WHERE situation LIKE '%\\%';
This did not returned any rows.

I looked up for a reference, confirmed that
"... double-backslash is required to represent a literal backslash."

But when I doubled the number of backslashes:
  SELECT smth. FROM  tbl WHERE situation LIKE '%\\\\%';
- it actually worked fine.

Same thing happens with using regex: situation ~ '\\';

Could someone shed some light on this, please.


In response to


pgsql-hackers by date

Next:From: Tom LaneDate: 2003-10-03 13:53:22
Subject: Re: minor view creation weirdness
Previous:From: Tom LaneDate: 2003-10-03 13:39:30
Subject: Re: Weird locking situation

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group