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 to 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?
有什么想法吗?使用多个值插入忽略是合法的吗?
2 个解决方案
#1
15
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.
请注意,varchar,text等值应该在引号内。
#2
2
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.
用上面的查询我没有发现任何问题。我认为你错过了引号括起来的字符串。
#1
15
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.
请注意,varchar,text等值应该在引号内。
#2
2
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.
用上面的查询我没有发现任何问题。我认为你错过了引号括起来的字符串。