X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BDED9D97CC for ; Wed, 21 Sep 2005 10:02:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82625-05 for ; Wed, 21 Sep 2005 13:01:55 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by svr1.postgresql.org (Postfix) with ESMTP id B0860D72AB for ; Wed, 21 Sep 2005 10:01:55 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 40so184356nzk for ; Wed, 21 Sep 2005 06:01:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=R2kVmY0D676Pi4G42uuh8x65RZao7liAxciVgENPsUgvc/Z7LbvRM86oousxuz6Be8t/hSzFiMZuI/Z6BOZIGbZ7jb3TDof8Zae/x1dOIty0hEjHl2JuBe8U1PO7p/7SORvxIiGy0hLzNAOht7QwpAKnpkwj8pzn7mab4UuKoiQ= Received: by 10.37.14.48 with SMTP id r48mr4557441nzi; Wed, 21 Sep 2005 06:01:59 -0700 (PDT) Received: by 10.36.120.14 with HTTP; Wed, 21 Sep 2005 06:01:59 -0700 (PDT) Message-ID: Date: Wed, 21 Sep 2005 18:31:59 +0530 From: Gnanavel S Reply-To: Gnanavel S To: Joost Kraaijeveld Subject: Re: How to add column from old_table to new_table? Cc: Pgsql-sql@postgresql.org In-Reply-To: <1127307055.20038.25.camel@Panoramix> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_415_21128290.1127307719092" References: <1127306186.20038.21.camel@Panoramix> <1127307055.20038.25.camel@Panoramix> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.292 required=5 tests=[AWL=0.181, HTML_40_50=0.086, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200509/185 X-Sequence-Number: 22732 ------=_Part_415_21128290.1127307719092 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/21/05, Joost Kraaijeveld wrote: > > Hi, > > I made a mistake in describing the query I tried. The query I tried was: > > update new_table > set new_attribute =3D (select old_attribute from old_table, new_table > where old_table.id =3D new_table.id) > where old_table.id =3D new_table.id It should be written has update new_table set new_attribute=3Dold_attribute from old_table where old_table.id=3Dnew_table.id; It actually returns the error "ERROR: more than one row returned by a > subquery used as an expression" if ran. > > > -- > Groeten, > > Joost Kraaijeveld > Askesis B.V. > Molukkenstraat 14 > 6524NB Nijmegen > tel: 024-3888063 / 06-51855277 > fax: 024-3608416 > e-mail: J.Kraaijeveld@Askesis.nl > web: www.askesis.nl > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster > -- with regards, S.Gnanavel Satyam Computer Services Ltd. ------=_Part_415_21128290.1127307719092 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On 9/21/05, Joost Kraaijeveld <J.Kraaijeveld@askesis.nl> wrote:
Hi,

I made a mistake in describing the query I tried. The query I tr= ied was:

update new_table
set new_attribute =3D (select old_attri= bute from old_table, new_table
where old_table.id =3D new_table.id)
w= here old_table.id =3D new_table.id

It should be written has

update new_table set new_attribute=3Dold_attribute from old_table where old= _table.id=3Dnew_table.id;

It actu= ally returns the error "ERROR:  more than one row returned b= y a
subquery used as an expression" if ran.


--
Groeten,

Joost Kraaijeveld
Askesis B.V.
Molu= kkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: = 024-3608416
e-mail: J.Kraaij= eveld@Askesis.nl
web: www.askesis.nl




---------------------------(end of broadcast)----------------= -----------
TIP 2: Don't 'kill -9' the postmaster



--
with regards,
S.Gnanavel
Satyam Comp= uter Services Ltd. ------=_Part_415_21128290.1127307719092--