UPDATE the field of a table with fields from another table

From: Balvie <ener(at)ibb(dot)nl>
To: pgsql-novice(at)postgresql(dot)org
Subject: UPDATE the field of a table with fields from another table
Date: 2006-10-15 20:22:41
Message-ID: 45329891.4070106@ibb.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I use: Postgres 7.3.10 and Pgadmin 1.4.3 on RH Linux

I got 2 tables with names and telephone numbers:

CREATE TABLE b1_naam
(
relcode varchar(10),
naam varchar(100),
telnr varchar(30)
)

CREATE TABLE b1_telco
(
relcode varchar(10),
telnr varchar(30),
ppc varchar(25)
)

and I need to restore some data. I created something like:

UPDATE b1_naam
SET telnr = t.telnr
FROM b1_telco as t
WHERE
b1_naam.relcode = b1_telco.relcode AND
b1_naam.naam like 'Bakke%';

Can anyone tell me what I did wrong? I have seen very complicated
statements with nested selects. I cannot believe that a simple query,
like the one I wrote above, is not available.

Thanks,

Balvie

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-10-15 20:46:57 Re: UPDATE the field of a table with fields from another table
Previous Message Sean Davis 2006-10-15 03:32:19 Re: -- New to read from Oracle and insert into Postgress