Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3TFuF337842 for ; Sun, 29 Apr 2001 11:56:15 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f3TFmfc65213 for pgsql-sql@postgresql.org; Sun, 29 Apr 2001 11:48:41 -0400 (EDT) (envelope-from news) From: "Ossie J. H. Moore" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: order of multiple assignments in UPDATE Date: Sun, 29 Apr 2001 10:30:34 +0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 66 Message-ID: <9chd4p$1vlq$1@news.tht.net> X-Complaints-To: scrappy@hub.org User-Agent: Pan/0.9.1 (Unix) X-No-Productlinks: Yes To: pgsql-sql@postgresql.org X-Archive-Number: 200104/433 X-Sequence-Number: 2795 While I'm not sure specificly which order they will be determined in, it has no effect on what the value of "c1" will be. The value of "c1" will be 10 minus the value of "c2" where "c2" equals the value it was before the update occurred. For exmple... 1. Assume you create the following table... create table temp ( c1 int2 , c2 int2 , c3 int2 ); 2. Insert the following row... insert into temp values (1,1,1); 3. Execute the following update command... update temp set c1 = (10-c2) , c2 = 5 , c3 = (10-c2); 4. Execute the following select... select * from temp; 5. Observe the following output... c1 c2 c3 == == == 9 5 9 You will note that both c1 and c3 equal 10 - 1. Neither equals 10-5. To make the value 10 - {the value after the update}, you would need to set the value to c1/c3 equal to the value of 10 - {the expression used to assign value to c2}. In the example above, your update statement would be... update temp set c1 = ( 10 - (5) ) , c2 = (5) , c3 = ( 10 - (5) ); In article , anuradha@gnu.org wrote: > > If I have a query > > UPDATE tablename SET c1 = 10 - c2, c2 = 4 where ... > > will the two assignments be evaluated from left to right? > > Thanks in advance. > > Anuradha > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly