mysql - 损坏的插入语句

标签 mysql sql insert

这个插入语句有什么问题?我看了好几遍了,也没看出哪里不对。

INSERT INTO tasks
       (task_id, priority, limit, total_active, time_limit, start_time, params)
VALUES ("d", "9", "1", "0", "1549699912", "1549696366", "");
+--------------+------------+------+-----+---------+----------------+
| Field        | Type       | Null | Key | Default | Extra          |
+--------------+------------+------+-----+---------+----------------+
| id           | int(11)    | NO   | PRI | NULL    | auto_increment |
| task_id      | varchar(2) | NO   |     | NULL    |                |
| priority     | tinyint(1) | NO   |     | 0       |                |
| limit        | int(11)    | NO   |     | NULL    |                |
| total_active | int(11)    | NO   |     | NULL    |                |
| time_limit   | int(11)    | NO   |     | NULL    |                |
| start_time   | int(11)    | NO   |     | NULL    |                |
| params       | tinytext   | YES  |     | NULL    |                |
+--------------+------------+------+-----+---------+----------------+

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 'limit, total_active, time_limit, start_time, params) VALUES ("1", "d", "9", "1",' at line 1

最佳答案

LIMIT 是sql中的关键字,需要在其周围添加双引号。

INSERT INTO tasks(task_id, priority, "limit", total_active, time_limit, 
    start_time, params) VALUES ("d", "9", "1", "0", "1549699912", "1549696366", "");

编辑:如果这不起作用,您可以使用反引号进行转义:

INSERT INTO tasks(task_id, priority, `limit`, total_active, time_limit, 
    start_time, params) VALUES ("d", "9", "1", "0", "1549699912", "1549696366", "");

关于mysql - 损坏的插入语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54604198/

相关文章:

php数组过滤数据插入到mysql

来自不同来源的 Oracle 过程插入

mysql - 有没有办法把这两个sql删除操作的逻辑结合起来呢?

sql - 如何按字符串的一部分进行选择和分组?

php - 重新排列表格行

sql 使连接的表成为一张表可能是什么?

sql - 来自 CDbCriteria 的 Yii SQL 查询

php - MySQL - 'INSERT INTO - ON DUPLICATE KEY UPDATE' 会导致数据丢失吗

MySQL加入Group By和Group Concat

mysql - 发生数据库错误 SELECT 列表的表达式 #1 不在 GROUP BY 子句中