select
id
from
tableABC
limit (select count(id) from tableCBA), 1如果我需要像我在示例代码中显示的那样在limit中进行选择,我如何在mySql中做到这一点?这只是本论坛的简化代码,否则这是复杂情况的一部分,否则选择。
发布于 2012-03-05 21:19:17
您不能直接为limit设置动态值,但可以在没有限制的情况下重写查询,如下所示:
set i := (select count(*) from tableCBA);
select id
from tableABC
where (i := i-1) = 0;这将返回第n行,其中n是tableCBA中的行数;
发布于 2012-03-05 21:16:24
select @LimitRowsCount1=count(id) from tableCBA;
PREPARE STMT FROM "SELECT id from tableABC LIMIT ?";
EXECUTE STMT USING @LimitRowsCount1; https://stackoverflow.com/questions/9567214
复制相似问题