0

I am trying to insert using this syntax:

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)

But keep getting the following error:

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',
systemdebt
  • 4,589
  • 10
  • 55
  • 116
  • Have you read the [documentation of the `INSERT` statement](https://dev.mysql.com/doc/refman/5.7/en/insert.html)? – axiac Jan 02 '18 at 18:06

1 Answers1

2

We use set to update the table or alter the table. To put value use this:

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);

Just for further information

Suppose you want to modify(Update) the price of the product id 1 from 700 to 750; In this case you have to use the keyword set which is counter part of Update. The query is as follows:

UPDATE salon_vendor_purchase_products
SET price= 750
WHERE product_id = 1;
Suvam Roy
  • 963
  • 1
  • 8
  • 19