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

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 (view raw or flat)
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

pgsql-novice by date

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

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