Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1

    Red face Unanswered: 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 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 = '11190 South Orange Avenue' 
    WHERE cust_name = 'Owl City'
    ;

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE customers 
       SET cust_address = '11190 South Orange Avenue' 
         , cust_contact = 'Todd Kamalfezchuk'
         , cust_email = 'todd@owlcity.com'
     WHERE cust_name = 'Owl City'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    I don't know why I pictured that being much harder in my head. I visualized column names and such in parenthesis for some strange reason.

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •