-1

有人可以快速帮助我吗,自从这篇文章以来,我已经坐了一个小时。

注意: (null) 是一个字符串,实际上不是一个 NULL 值...应该本质上与使用 'Hello' 作为值相同

INSERT INTO tasks (category,completion_dtm,desc,duedate,notification_duedate,notification_one,notification_two,priority,reminder_one,reminder_two,title,timestamp) VALUES('None','3999-01-01 00:00:00','(null)',('1000-01-01 00:00:00'),'(null)','(null)','(null)',2,('1000-01-01 00:00:00'),('1000-01-01 00:00:00'),'Task 3',('1000-01-01 00:00:00')) ON DUPLICATE KEY UPDATE id=VALUES(id)

我的语法有什么问题吗?感谢您的任何见解!

编辑:对不起,认为错误很明显:

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 'desc,duedate,notification_duedate,notification_one,notification_two,priority,rem' at line 1
4

3 回答 3

1

第一眼——

desc是一个mysql保留字,你必须用反引号把它括起来``

NSERT INTO tasks (category,completion_dtm,`desc`,duedate,notification_duedate,notification_one,notification_two,priority,reminder_one,reminder_two,title,timestamp) VALUES('None','3999-01-01 00:00:00','(null)',('1000-01-01 00:00:00'),'(null)','(null)','(null)',2,('1000-01-01 00:00:00'),('1000-01-01 00:00:00'),'Task 3',('1000-01-01 00:00:00')) ON DUPLICATE KEY UPDATE id=VALUES(id)

如果您发布确切的 SQL 错误消息,我们可以提供更接近的答案。

于 2012-02-29T11:04:46.077 回答
1

您有与 mysql 关键字匹配的列名 在列名中使用反引号

于 2012-02-29T11:07:51.333 回答
1

除了desc作为关键字之外,还值得检查您在日期上指定的值。我相信您已超过允许的日期限制或小于允许的最短日期。首先检查语句是否会成功,日期为当前日期。

于 2012-02-29T11:12:19.580 回答