Received: from msgin1.anpe.fr (nsmail@smtp1.anpe.fr [195.101.137.20]) by hub.org (8.9.3/8.9.3) with ESMTP id DAA24499 for ; Wed, 1 Dec 1999 03:49:14 -0500 (EST) (envelope-from patrick.jacquot@anpe.fr) Received: from antivirus.anpe.fr ([10.0.4.95]) by msgin1.anpe.fr (Netscape Messaging Server 3.6) with SMTP id AAA246F for ; Wed, 1 Dec 1999 09:50:50 +0100 Sender: pjacquot Message-ID: <3844EB46.EDFA7129@anpe.fr> Date: Wed, 01 Dec 1999 10:32:55 +0100 From: Patrick JACQUOT Organization: DSI Noisiel X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.9-19mdk i586) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgreSQL.org Subject: Re: [SQL] found a way to update a table with data from another one References: <20827.943975363@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Tom Lane wrote: > Patrick JACQUOT writes: > > I found a simpler way to do the job I wanted done > > > UPDATE t1 SET balance = balance+t2.amount WHERE EXISTS (SELECT * > > FROM t2 WHERE t2.id = t1.id) > > > DOES WORK PROPERLY. > > Does it? I don't think that this will do what you are expecting, I thank you very much for your advice. I didn't try indeed to put more than one line in T2. I tried before to use your approach bu i used the wrong syntax : UPDATE t1 SET Balance=Balance+(SELECT Amount FROM t2 WHERE t2.id=t1.id); which gave me 'parser : parser error near select'. I am really sorry havig done such a mistake, and apologize Next time i'll turn my tongue seven times in my mouth before going to my keyboard. Best regards P. Jacquot