dbTalk Databases Forums  

[SQL] UPDATE Multiple Records At Once?

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss [SQL] UPDATE Multiple Records At Once? in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Carlos Mennens
 
Posts: n/a

Default [SQL] UPDATE Multiple Records At Once? - 04-11-2012 , 12:50 PM






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 (AT) mobilenx (DOT) 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?

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: [SQL] UPDATE Multiple Records At Once? - 04-11-2012 , 03:55 PM






Carlos Mennens wrote on 11.04.2012 19:50:
Quote:
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 (AT) mobilenx (DOT) 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 (AT) foo (DOT) bar'
WHERE cust_name = 'iamUNIX'


--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.