Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C55292E009F for ; Thu, 20 Mar 2008 11:28:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 70040-02 for ; Thu, 20 Mar 2008 11:28:50 -0300 (ADT) X-Greylist: delayed 00:49:50.872117 by SQLgrey-1.7.5 Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) by postgresql.org (Postfix) with ESMTP id B36AE2E0084 for ; Thu, 20 Mar 2008 11:28:50 -0300 (ADT) Received: from [192.168.2.5] ([96.228.149.47]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JY1003TY7DLUK00@vms040.mailsrvcs.net> for pgsql-sql@postgresql.org; Thu, 20 Mar 2008 08:41:46 -0500 (CDT) Date: Thu, 20 Mar 2008 09:38:23 -0400 From: Joe Subject: Re: Select into In-reply-to: <65937bea0803200613k4593da12hd62233f8a745309@mail.gmail.com> To: Gurjeet Singh Cc: Gavin 'Beau' Baumanis , pgsql-sql@postgresql.org Message-id: <47E268CF.3040604@freedomcircle.net> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <94F93C0F-DA95-4435-B253-57C90961DF34@eclinic.com.au> <20080320104922.GB18935@a-kretschmer.de> <65937bea0803200358i290bdc87hdeca777b593b5df1@mail.gmail.com> <786D2B38-CE0A-41BF-9E70-4DEB22F8D9EF@eclinic.com.au> <47E25447.6040109@freedomcircle.net> <65937bea0803200613k4593da12hd62233f8a745309@mail.gmail.com> User-Agent: Thunderbird 1.5.0.9 (X11/20080117) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/148 X-Sequence-Number: 30476 Gurjeet Singh wrote: > Except that it doesn't work... Did you try to execute that query; I am > assuming not. Of course I did, do you think I create results by editing them into my email? The script: delete from t1; insert into t1 values (1, 123, 'first record'); insert into t1 values (2, 456, 'second record'); insert into t1 values (3, 789, 'third record'); select * from t1; update t1 set col2 = t1copy.col2, col3 = t1copy.col3 from t1 as t1copy where t1.col1 = 1 and t1copy.col1 = 3; select * from t1; select version(); The output: DELETE 3 INSERT 0 1 INSERT 0 1 INSERT 0 1 col1 | col2 | col3 ------+------+--------------- 1 | 123 | first record 2 | 456 | second record 3 | 789 | third record (3 rows) UPDATE 1 col1 | col2 | col3 ------+------+--------------- 2 | 456 | second record 3 | 789 | third record 1 | 789 | third record (3 rows) version ------------------------------------------------------------------------ PostgreSQL 8.1.9 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.3 (1 row) And BTW, I also tried your UPDATE SET (salary, name) but that only works on PG 8.2 and above. I don't see why my query would fail in subsequent releases. Joe