Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql- can I do INSERT IGNORE with multiple values?

Tags:

mysql

insert

I have the following code:

INSERT IGNORE INTO unsubscribes (email) VALUES ([email protected]),([email protected]),([email protected]),([email protected])

but it repeatedly returns an error...

The error is:

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 '@john.com),([email protected]),([email protected]),(another' at line 1

Any ideas why? It is legal to do insert ignore with multiple values right?

like image 844
Mazatec Avatar asked Apr 01 '11 10:04

Mazatec


2 Answers

Put the values inside quotes.

This will work

INSERT IGNORE INTO unsubscribes (email) 
VALUES ('[email protected]'),
       ('[email protected]'),
       ('[email protected]'),
       ('[email protected]')

Note that varchar, text etc values should be inside the quotes.

like image 135
Shakti Singh Avatar answered Oct 19 '22 23:10

Shakti Singh


INSERT IGNORE INTO unsubscribes (email) 
VALUES ('[email protected]'),('[email protected]'),('[email protected]'),('[email protected]');

with the above query i don't find any issues. I think that you have missed quotes to enclose string.

like image 40
Roshan Avatar answered Oct 20 '22 00:10

Roshan