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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Markus Bertheau" <mbertheau(dot)pg(at)googlemail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: UPDATE .. FROM
Date: 2008-03-07 13:47:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
"Markus Bertheau" <mbertheau(dot)pg(at)googlemail(dot)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 = AND =  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

In response to

pgsql-sql by date

Next:From: Jamie TufnellDate: 2008-03-07 15:33:28
Subject: Re: Composite UNIQUE across two tables?
Previous:From: Yura GalDate: 2008-03-07 13:23:36
Subject: Re: RETURN QUERY generates error

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