在 LIMIT 子句中使用算术运算符 and/or 括号

Using arithmetic operators and/or brackets in a LIMIT clause

我在存储过程的查询中有以下小子查询。

(select f_cnt from results limit (i-1)*10,i*10)

但是有语法错误:

"(" is not valid at this position, expecting an identifier

所以,问题是:我可以在 LIMIT 子句中使用方括号 and/or 算术运算符吗?

文档说我可以在存储过程中的 LIMIT 子句中使用局部变量。我真的需要为这种情况声明和设置不同的变量吗?

为了以防万一,link为了存储过程的代码。

那时你不能算术

所以这样做

SET @sql := CONCAT("SELECT * FROM TEsttable WHERE id In(select f_cnt from results limit ",(i-1) * 10,",",i*10,")");
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

哪个会产生

SELECT * FROM TEsttable WHERE id In(select f_cnt from results limit 90,100)