pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Markus Bertheau <mbertheau.pg@googlemail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: UPDATE .. FROM
Date: Fri, 07 Mar 2008 08:47:41 -0500
Message-ID: <12016.1204897661@sss.pgh.pa.us> (raw)
In-Reply-To: <684362e10803070513sc3781d6ud05019831afd570d@mail.gmail.com>
References: <684362e10803070513sc3781d6ud05019831afd570d@mail.gmail.com>

"Markus Bertheau" <mbertheau.pg@googlemail.com> writes:
> I'm kind of stuck as to why postgresql doesn't understand what I mean in the
> following queries:

> UPDATE tag_data td SET td.usage_counter = td.usage_counter + 1 FROM
> tag_list_tag_data ltd WHERE ltd.tag_id = td.id AND ltd.id =  102483;
> ERROR:  column "td" of relation "tag_data" does not exist

You aren't supposed to specify a table name (nor alias) for a target
variable in a SET clause.  It's useless (since you can't update more
than one table) and it's ambiguous because of the possibility of
composite fields.  What you want is something like

UPDATE tag_data td SET usage_counter = td.usage_counter + 1 FROM ...

			regards, tom lane



view thread (2+ messages)

Message-ID: <12016.1204897661@sss.pgh.pa.us>
Permalink:  ../12016.1204897661@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12016.1204897661@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mbertheau.pg@googlemail.com
  Subject: Re: UPDATE .. FROM
  In-Reply-To: <12016.1204897661@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox