PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 11th, 2012, 02:04 PM
CarlosinFL CarlosinFL is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 51 CarlosinFL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 8 m 48 sec
Reputation Power: 2
UPDATE Multiple Values From One Column

This is very basic for mostly everyone browsing this forum however I'm stuck and Google isn't giving me what I need and/or I can't seem to use the correct terminology to locate my answer. What I'm trying to do is update a single customer record from a table called 'customers'. They've moved and also changed their staff. I've been tasked to update the records :shocked: in the table to make sure we have their most up to date info. As it stands, their info is as follows:

Code:
forta=# SELECT cust_id, cust_name, cust_address, cust_contact, cust_email
forza-# FROM customers
forza-# WHERE cust_name LIKE 'Owl City'
forza-# ;
  cust_id   | cust_name |     cust_address     | cust_contact |    cust_email
------------+-----------+----------------------+--------------+-------------------
 1000000010 | Owl City  | 7991 Maitland Avenue | Perry Gold   | perry@owlcity.org
(1 row)


Can someone please help me understand what the UPDATE command would look like if I needed to change the values for (cust_address, cust_contact, cust_email) rather than running the update command three times with different values?

Code:
UPDATE customers SET (cust_address, cust_contact, cust_email) VALUES ('1119 Orange Avenue', 'Jennifer Gold', 'jennifer@owlcity.org') WHERE cust_name = 'Owl City';
ERROR:  syntax error at or near "VALUES"
LINE 1: ...mers SET (cust_address, cust_contact, cust_email) VALUES ('1...

Reply With Quote
  #2  
Old April 11th, 2012, 05:29 PM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,684 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 38 m
Reputation Power: 284
Code:
UPDATE customers 
   SET cust_address = '1119 Orange Avenue', 
       cust_contact = 'Jennifer Gold', 
       cust_email = 'jennifer@owlcity.org' 
WHERE cust_name = 'Owl City';

As documented in the manual:
http://www.postgresql.org/docs/current/static/sql-update.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > UPDATE Multiple Values From One Column

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


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

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap