How to escape apostrophes when apostrophes already used to escape something else

From: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: How to escape apostrophes when apostrophes already used to escape something else
Date: 2010-02-05 09:13:21
Message-ID: 39ADEF4E-E903-463C-9D31-C01C4E05407E@grid.unep.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

probably not too complicated, but although googling my way through
many pages, I don't find the solution.

I have a query which uses already an apostrophe to escape something
else:

$query = "SELECT
*
FROM
crosstab('SELECT
COALESCE(c.name, '''') AS name,
d.year_start AS year,
d.value AS value
FROM
co2_total_cdiac AS d
RIGHT JOIN
countries_view AS c ON c.id = d.id_country
WHERE
(d.year_start = 1960 ) AND
(c.name = ''Cote d'Ivoire'' )
ORDER BY
1,2;', 3) AS ct(name varchar, y_1960 numeric)

Now, "Cote d'Ivoire" needs to be escaped too. But how can I achieve
this?

Thanks for any hints.

Stef

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2010-02-05 09:21:50 Re: How to escape apostrophes when apostrophes already used to escape something else
Previous Message dipti shah 2010-02-05 09:08:26 Re: SSL connection option from client side?