Re: UPDATE Syntax Check

From: David Johnston <polobo(at)yahoo(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: UPDATE Syntax Check
Date: 2012-06-13 00:51:13
Message-ID: B55817EF-85EE-4C3F-BB02-DA01EE585CF2@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jun 12, 2012, at 18:50, Rich Shepard <rshepard(at)appl-ecosys(dot)com> wrote:

> On Wed, 13 Jun 2012, Thomas Kellerer wrote:
>
>> UPDATE waterchem
>> SET waterchem.easting = s.easting
>> waterchem.northing = s.northing
>> FROM sites AS s
>> WHERE waterchem.site = s.name;
>
> Thomas,
>
> For the record, running this pushed me to the correct syntax:
>
> UPDATE waterchem
> SET easting = s.easting
> northing = s.northing
> FROM sites AS s
> WHERE waterchem.site = s.name;
>
> The target does not want the table name repeated; postgres looks for a
> column named 'waterchem.easting'.
>
> Regards,
>
> Rich
>

You are right regarding the table name in the set portion, it has to be the specified table. However, you can alias the table so that instead of waterchem.site you could do something like wc.site
And, to be thorough, you need to put commas between each field you want to update.

easting = s.easting, northing = s.northing

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-06-13 02:11:23 Re: Problem installing extensions on Lion
Previous Message Jeff Davis 2012-06-12 23:40:39 Re: trigger on view returning created serial