mysql- can I do INSERT IGNORE with multiple values?
I have the following code:
INSERT IGNORE INTO unsubscribes (email)
VALUES (john@john.com),(kevin@kevin.com),(mike@mike.com),(another@gmail.com)
but it repeatedly returns an error...
The error is:
You have an error in your SQL syntax; check the manual that corresponds t开发者_高级运维o your MySQL server version for the right syntax to use near
'@john.com),(kevin@kevin.com),(mike@mike.com),(another'
at line 1
Any ideas why? It is legal to do insert ignore with multiple values right?
Put the values inside quotes.
This will work
INSERT IGNORE INTO unsubscribes (email)
VALUES ('john@john.com'),
('kevin@kevin.com'),
('mike@mike.com'),
('another@gmail.com')
Note that varchar, text etc values should be inside the quotes.
INSERT IGNORE INTO unsubscribes (email)
VALUES ('john@john.com'),('kevin@kevin.com'),('mike@mike.com'),('another@gmail.com');
with the above query i don't find any issues. I think that you have missed quotes to enclose string.
精彩评论