1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Rep Power

    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:

    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?

    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...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Rep Power
    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:

IMN logo majestic logo threadwatch logo seochat tools logo