mysql-我可以用多个值插入忽略吗?
我有以下代码:mysql-我可以用多个值插入忽略吗?,mysql,insert,Mysql,Insert,我有以下代码: INSERT IGNORE INTO unsubscribes (email) VALUES (john@john.com),(kevin@kevin.com),(mike@mike.com),(another@gmail.com) 但它会反复返回一个错误 错误是: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th
INSERT IGNORE INTO unsubscribes (email) VALUES (john@john.com),(kevin@kevin.com),(mike@mike.com),(another@gmail.com)
但它会反复返回一个错误
错误是:
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
你知道为什么吗?使用多个值插入或忽略是合法的,对吗?将值放在引号内 这会奏效的
INSERT IGNORE INTO unsubscribes (email)
VALUES ('john@john.com'),
('kevin@kevin.com'),
('mike@mike.com'),
('another@gmail.com')
请注意,varchar、text等值应位于引号内
INSERT IGNORE INTO unsubscribes (email)
VALUES ('john@john.com'),('kevin@kevin.com'),('mike@mike.com'),('another@gmail.com');
通过以上查询,我没有发现任何问题。我认为您遗漏了用引号括起来的字符串。您会遇到什么错误?您想做什么>?错误已在上面发布-我正在尝试将多行发布到我的表中,如果其中一个值已存在,我不希望它再次发布。。。非常标准为列使用唯一键以避免重复值IQUE键在此实例中不合适,因为在插入重复视图时它会引发错误。现在我得到错误-未知列的john@john.com'在'field list'@Ash:从我的回答中复制,再试一次,因为我是哑巴,可能还有其他哑巴:不要把列名加引号s