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

Re: finding strings with quotes

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Christine Penner <chris(at)fp2(dot)ca>
Cc: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: finding strings with quotes
Date: 2011-02-26 09:47:31
Message-ID: 154815D8-5949-4B33-B0D7-1A6FCE6A5869@solfertje.student.utwente.nl (view raw or flat)
Thread:
Lists: pgsql-general
On 25 Feb 2011, at 21:45, Christine Penner wrote:

> I'm trying to do a select to find on a char field that has a single quote but getting errors. This is what I'm doing:
> 
> Select * from f_buildings where B_STRET_LNE_CON='BERLETT\'S ROAD'
> 
> The text I'm trying to find is BERLETT'S ROAD
> 
> If I do the same thing but have double quotes in the string instead of single quotes this works.

You probably have set standard_conforming_strings to 'on'.
In that case you should either use:
	SELECT E'BERLETT\'S ROAD';
	SELECT 'BERLETT''S ROAD';
Or set standard_conforming_strings TO 'off', in which case you'll just get a warning.


Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


!DSPAM:737,4d68cc3d11735859949296!



In response to

pgsql-general by date

Next:From: franco egiziiDate: 2011-02-26 12:05:29
Subject: Website code Pl/pgsql
Previous:From: Andy ColsonDate: 2011-02-26 05:26:04
Subject: Re: slow building index and reference after Sybase to Pg

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