,我很难理解我所犯错误背后的原因及其解决方案。
mysql> explain times;
+------------+-------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| person_id | int(11) | YES | | NULL | |
| desc | varchar(30) | YES | | NULL | |
| in | timestamp | NO | | CURRENT_TIMESTAMP | |
| out | timestamp | NO | | 0000-00-00 00:00:00 | |
| clocked_in | tinyint(1) | NO | | 1 | |
+------------+-------------+------+-----+---------------------+----------------+
6 rows in set (0.00 sec)当我试图将值插入时间表时,我使用这个命令得到了这个错误。
mysql> insert into times(person_id, desc) values(1,'stuff');
ERROR 1064 (42000): 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) values(1,'stuff')' at line 1,但是不管出于什么原因,主要是因为我不得不用东西来刻划我用的
insert into times(person_id, `desc`) values(1, 'stuff')然后
Query OK, 1 row affected (0.05 sec)为什么要这样做??
发布于 2014-11-18 07:06:25
desc是MySQL中的一个保留字,在作为列引用时必须用`字符包围。
desc是一个排序顺序,指示MySQL按降序排序返回的结果。
请参阅:http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html
发布于 2014-11-18 07:06:54
desc是mysql或sql或任何其他描述降序的数据库中的关键字,但当使用'desc'时,会将其作为列名。
发布于 2014-11-18 07:08:11
DESC和IN是mysql中的两个关键词。
https://stackoverflow.com/questions/26988476
复制相似问题