April 11th, 2012, 03:04 PM
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:
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?
forta=# SELECT cust_id, cust_name, cust_address, cust_contact, cust_email
forza-# FROM customers
forza-# WHERE cust_name LIKE 'Owl City'
cust_id | cust_name | cust_address | cust_contact | cust_email
1000000010 | Owl City | 7991 Maitland Avenue | Perry Gold | firstname.lastname@example.org
UPDATE customers SET (cust_address, cust_contact, cust_email) VALUES ('1119 Orange Avenue', 'Jennifer Gold', 'email@example.com') WHERE cust_name = 'Owl City';
ERROR: syntax error at or near "VALUES"
LINE 1: ...mers SET (cust_address, cust_contact, cust_email) VALUES ('1...
April 11th, 2012, 06:29 PM
As documented in the manual:
SET cust_address = '1119 Orange Avenue',
cust_contact = 'Jennifer Gold',
cust_email = 'firstname.lastname@example.org'
WHERE cust_name = 'Owl City';