此查询
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
它指的是什么语法错误?我试着用分号或引号将语句括起来,但都不起作用。
正如您在mysql文档中看到的,您只能在Limit中给出行数,而不能给出偏移量。
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
Cange你查询到
UPDATE `sites_configuration` SET `configuration_value`= `value`
WHERE `configuration_id` = 41 AND `sites_id` = 2 LIMIT 30
您不能通过更新其无效来指定集合的限制
错误:限制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 |
+------------+--------+--------+
LIMIT 0,30
在更新查询中没有意义。尝试LIMIT 30
。