Re: [SQL] Update with two tables??

From: Fomichev Michael <fomichev(at)null(dot)ru>
To: Mark <mlundquist(at)bvsdps(dot)com>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Update with two tables??
Date: 1999-06-16 21:15:11
Message-ID: Pine.LNX.4.04.9906171012560.352-100000@ns.region.utsr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Wed, 16 Jun 1999, Mark wrote:

> I am trying to update table A with data from table B. I thought I could do
> something like:
>
> UPDATE A
> SET A.name = B.name
> WHERE A.id = B.id
> FROM B
>
> but alas, this does not work.
>
> Anyone have an idea of how I can do this?

It works. But you don't need A.name:
UPDATE A
SET name = B.name
FROM B
WHERE A.id = B.id;

@------------------+-----------------------------------------------@
| Fomichev Mikhail | The Government of Kamchatka region. |
| Vladimirovich | The Labour and Social Development Department. |
|<fomichev(at)null(dot)ru>| |
@------------------+-----------------------------------------------@

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Henry B. Hotz 1999-06-16 23:25:15 Re: [HACKERS] Postgres mailing lists
Previous Message Fomichev Michael 1999-06-16 21:12:39 Re: [SQL] Updating