The official seems to have said that limit has supported dynamic parameters on version 5.6, but it still doesn't work when testing.
The only way to solve the limit dynamic parameter is to use a string of SQL concatenation and then execute it.
Generally there are the following ways to solve:
1, the storage process splicing
2. Function stitching
3. Stitching in view
4. Use in session of current query
In fact, this is the same meaning, is to use a variable to access the SQL, and then execute the variable.
Examples:
Set @stmt =Concat'SELECT * from', TABLE_NAME,'Limit?,?');PrepareS1 from @stmt;Set @s1 =Page_begin;Set @s2 =Page_end;ExecuteS1 using@s1,@s2;deallocate PrepareS1;
Reference:
http://blog.csdn.net/hellolongbin/article/details/1999817
http://blog.csdn.net/yongsheng0550/article/details/6217917
http://blog.csdn.net/xinyuan_java/article/details/50056741
MySQL in limit uses dynamic parameter resolution (stitching SQL string statements to execute SQL)