MYSQL Updating multiple columns using variables

Viewed 45087

I used this query to insert all my values into this database:

INSERT INTO products ($fields) VALUES ($values)

However, I try to use the same format for UPDATE:

UPDATE products SET ($fields) VALUES ($values) WHERE sku = '$checksku'

...and am getting thrown a syntax error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('product,make,model,' at line 1

I can't figure it out. Would appreciate any help. Thanks.

3 Answers
INSERT INTO products ($fields) VALUES ($values) ON DUPLICATE KEY UPDATE field = VALUES(field), ...

Don't forgot about unique or primary key

Related