INSERT INTO SET的mysql语法

时间:2018-01-02 17:47:03

标签: mysql

我正在尝试使用以下语法插入:

INSERT  INTO salon_vendor_purchase_products(invoice_num, product_id, quantity, price) SET (\'65786\', 1, 1, 700), (\'65786\', 2, 1, 900), (\'65786\', 3, 1, 1700)

但是不断收到以下错误:

sqlMessage: '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 \'SET (\'65786\', 1, 1, 700), (\'65786\', 2, 1, 900), (\'65786\', 3, 1, 1700)\' at line 1',

1 个答案:

答案 0 :(得分:2)

我们使用set更新表或更改表。为了增加价值,请使用:

INSERT  INTO salon_vendor_purchase_products values(65786, 1, 1, 700) ; 
INSERT  INTO salon_vendor_purchase_products values(65786, 2, 1, 900);
INSERT  INTO salon_vendor_purchase_products values(65786, 3, 1, 1700);
  

仅供参考

假设您要将产品ID 1的价格从700修改(更新)到750; 在这种情况下,您必须使用与Update相对应的关键字set。查询如下:

UPDATE salon_vendor_purchase_products
SET price= 750
WHERE product_id = 1;