此查询
UPDATE `sites_configuration` SET `configuration_value`= `value`
WHERE `configuration_id` = 41 AND `sites_id` = 2 LIMIT 0, 30
给我这个错误
#1064 - 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 ' 30' at line 1
它指的是什么语法错误?我尝试使用分号或将语句包装在引号中,但它不起作用。
答案 0 :(得分:3)
LIMIT 0,30
在更新查询中没有意义。试试LIMIT 30
。
答案 1 :(得分:3)
正如您在mysql documentation中所看到的,您只能在限制中提供行数而不是偏移量。
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
让您查询
UPDATE `sites_configuration` SET `configuration_value`= `value`
WHERE `configuration_id` = 41 AND `sites_id` = 2 LIMIT 30
答案 2 :(得分:3)
您无法通过更新其无效
来指定限制偏移错误:限制0,10
但您可以指定为
update table set val = 'something' limit 30
这是一个演示
mysql> select * from test ;
+------------+--------+--------+
| Date | Person | Action |
+------------+--------+--------+
| 2014-01-01 | John | Enter |
| 2014-01-01 | lilly | Enter |
| 2014-01-01 | bill | Enter |
| 2014-01-01 | bill | Enter |
| 2014-01-02 | bill | Enter |
| 2014-01-02 | lilly | Enter |
| 2014-01-02 | bill | Enter |
| 2014-01-02 | John | Enter |
| 2014-01-02 | John | Enter |
+------------+--------+--------+
9 rows in set (0.02 sec)
mysql> update test set Action = 'GO' limit 0,5;
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 '5' at line 1
mysql> update test set Action = 'GO' limit 5;
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> select * from test ;
+------------+--------+--------+
| Date | Person | Action |
+------------+--------+--------+
| 2014-01-01 | John | GO |
| 2014-01-01 | lilly | GO |
| 2014-01-01 | bill | GO |
| 2014-01-01 | bill | GO |
| 2014-01-02 | bill | GO |
| 2014-01-02 | lilly | Enter |
| 2014-01-02 | bill | Enter |
| 2014-01-02 | John | Enter |
| 2014-01-02 | John | Enter |
+------------+--------+--------+