Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 25CFD2D0B10 for ; Fri, 10 Feb 2012 11:33:26 -0400 (AST) Received: from iota.marktest.pt ([80.251.174.118] helo=hermes.marktest.pt) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RvsTV-0006Uo-PV for pgsql-sql@postgresql.org; Fri, 10 Feb 2012 15:33:26 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by hermes.marktest.pt (Postfix) with ESMTP id C011F1A83A5; Fri, 10 Feb 2012 15:33:11 +0000 (WET) X-Virus-Scanned: amavisd-new at marktest.pt Received: from hermes.marktest.pt ([127.0.0.1]) by localhost (hermes.marktest.pt [127.0.0.1]) (amavisd-new, port 11124) with ESMTP id xyYRi9dsZYAQ; Fri, 10 Feb 2012 15:33:11 +0000 (WET) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by hermes.marktest.pt (Postfix) with ESMTP id 8A5461A83A3; Fri, 10 Feb 2012 15:33:11 +0000 (WET) Message-ID: <3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt> From: "Oliveiros d'Azevedo Cristina" To: "ssylla" , References: <1328752685274-5468330.post@n5.nabble.com> Subject: Re: update column Date: Fri, 10 Feb 2012 15:33:09 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Pg-Spam-Score: 1.5 (+) X-Archive-Number: 201202/36 X-Sequence-Number: 36329 UPDATE admin SET parent = SUBSTR(id,1,4); Doesn't it do what you want? Best, Oliveiros ----- Original Message ----- From: "ssylla" To: Sent: Thursday, February 09, 2012 1:58 AM Subject: [SQL] update column > Dear list, > > sorry, I already posted this, but it did not seem to have been accepted by > the mailing list. So here's my second try: > > I need to update all rows of a column ('parent') based on a subquery that > returns me the first four digits of another column ('id'): > > UPDATE admin SET parent=(SELECT SUBSTR(id,1,4) FROM admin); > > > After executing, I get the following error-message: > > "more than one row returned by a subquery used as an expressionmore than > one > row returned by a subquery used as an expression" > > > I am not quite sure about that, but maybe I need to construct a > function/loop to fulfill this task? > > thanks for help. > > Stefan > > -- > View this message in context: > http://postgresql.1045698.n5.nabble.com/update-column-tp5468330p5468330.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql