Re: Table name specified more than once

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Alexander Mueller <Alexander(dot)Mueller(at)SurfControl(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Table name specified more than once
Date: 2003-06-13 16:17:26
Message-ID: fotjevcvhljovir89cnl5mbga5mhr41uir@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 13 Jun 2003 17:07:28 +0200, Alexander Mueller
<Alexander(dot)Mueller(at)SurfControl(dot)com> wrote:
>It results in a "Table name "Workstations" specified more than once" error
>message. Can anyone help me with correcting the syntax?

Don't include the table you want to update in the FROM list:

UPDATE onetable
SET col1 = othertable.cola, col2 = othertable.colb
FROM othertable
WHERE onetable.x = othertable.y;

In your case othertable is the subselect and the JOIN condition moves
to the WHERE clause.

>copying, distribution or any action taken or omitted to be taken in
>reliance on it, is prohibited and may be unlawful.

Am I going to be arrested? :-(

Servus
Manfred

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ian Barwick 2003-06-13 16:28:28 Re: How can I insert a UTF-8 character with psql?
Previous Message Lamar Owen 2003-06-13 16:10:58 Re: [HACKERS] SAP and MySQL ... [and Benchmark]