Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A903C2E01D6 for ; Fri, 7 Mar 2008 09:47:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57046-02 for ; Fri, 7 Mar 2008 09:47:43 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id DC8072E024A for ; Fri, 7 Mar 2008 09:47:43 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m27Dlful012017; Fri, 7 Mar 2008 08:47:41 -0500 (EST) To: "Markus Bertheau" cc: pgsql-sql@postgresql.org Subject: Re: UPDATE .. FROM In-reply-to: <684362e10803070513sc3781d6ud05019831afd570d@mail.gmail.com> References: <684362e10803070513sc3781d6ud05019831afd570d@mail.gmail.com> Comments: In-reply-to "Markus Bertheau" message dated "Fri, 07 Mar 2008 19:13:19 +0600" Date: Fri, 07 Mar 2008 08:47:41 -0500 Message-ID: <12016.1204897661@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/42 X-Sequence-Number: 30370 "Markus Bertheau" 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