我想知道是否有人可以在我的 sql 语句中发现任何错误。如果一个新记录不存在,我希望它在我的表中插入一条新记录。如果它确实存在,那么只需更新它。我在日期字段中的主键。
这是我在 php 中出现的声明以及我得到的错误:
INSERT INTO ExtraStats (date, supportStaff, startEmails, endEmails, emailsAnswered) VALUES ('$startDate', '$supportStaff', '$startEmail', '$endEmail', '$emailAnswered') ON DUPLICATE KEY UPDATE (supportStaff, startEmails, endEmails, emailsAnswered) VALUES ('$supportStaff', '$startEmail', '$endEmail', '$emailAnswered')
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 '(supportStaff, startEmails, endEmails, emailsAnswered) VALUES ('2', '3', '1', '3' at line 1