Rose
Rose

Reputation: 600

duplicate key update

I'm trying to run the following query in MySQL,

INSERT IGNORE INTO shop_item_details (shop_id,product_id,product_name,Product_model,Product_category,Product_details,price) 
 VALUES (1, NULL, 'camera', 'sony','', 'hd', '5000') 
 ON DUPLICATE KEY 
 UPDATE (shop_id='1',product_id='',product_name='camera', Product_model='sony',Product_category='', Product_details='hd',price='5000')

But it shows the following error:

#1064 - 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 '(shop_id='1',product_id='',product_name='camera', Product_model='sony',Product_c' at line 1

What's wrong with my query?

Upvotes: 0

Views: 47

Answers (2)

Ilyes GHOMRANI
Ilyes GHOMRANI

Reputation: 122

you just need to remove the brakets around update

ON DUPLICATE KEY UPDATE shop_id='1' ,product_id='', product_name='camera', Product_model='sony', Product_category='', Product_details='hd', price='5000';

Upvotes: 0

4EACH
4EACH

Reputation: 2197

This good one:

INSERT IGNORE INTO shop_item_details (shop_id,product_id,product_name,Product_model,Product_category,Product_details,price) 
 VALUES (1, NULL, 'camera', 'sony','', 'hd', '5000') 
 ON DUPLICATE KEY UPDATE shop_id='1',product_id='',product_name='camera', Product_model='sony',Product_category='', Product_details='hd',price='5000';

remove brackets around update

Upvotes: 3

Related Questions