Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4E3F9F765A for ; Wed, 11 Apr 2012 17:55:35 -0300 (ADT) Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SI4Zi-000791-7t for pgsql-sql@postgresql.org; Wed, 11 Apr 2012 20:55:35 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SI4ZR-0007I8-CQ for pgsql-sql@postgresql.org; Wed, 11 Apr 2012 22:55:17 +0200 Received: from ppp-188-174-71-110.dynamic.mnet-online.de ([188.174.71.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Apr 2012 22:55:17 +0200 Received: from spam_eater by ppp-188-174-71-110.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Apr 2012 22:55:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: Re: UPDATE Multiple Records At Once? Date: Wed, 11 Apr 2012 22:55:08 +0200 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ppp-188-174-71-110.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/27 X-Sequence-Number: 36504 Carlos Mennens wrote on 11.04.2012 19:50: > I'm trying to update a customer record in a table however I need to > change several values (cust_address, cust_contact, cust_email). My > question is how do I properly format this into one single command? > > > forza=# SELECT cust_id, cust_name, cust_address, cust_contact, cust_email > forza-# FROM customers > forza-# WHERE cust_name = 'iamUNIX' > forza-# ; > cust_id | cust_name | cust_address | cust_contact | > cust_email > ------------+-----------+-----------------------+----------------+-------------------- > 1000000006 | MobileNX | 200 South Shore Drive | Carlos Mennens | > carlos@mobilenx.com > (1 row) > > I did a quick Google search and I can see there is a method or > procedure which involves parenthesis () however I'm not sure how I > would change all the values listed above under one command. Can anyone > please give me a quick example so I can see how this is drawn out via > ANSI SQL? > UPDATE customers SET cust_address = 'foo', cust_contact = 'Arthur', cust_email = 'arthur@foo.bar' WHERE cust_name = 'iamUNIX'