1, high version of MySQL (5.5), the stored procedure limit can use variables, as follows: SELECT * from student limit istart,inum;
2, the low version of MySQL (5.1), stored in the process of limit can not use variables, compile error, as follows: You have a error in your SQL syntax, ... near Istart,inum
3, how to solve the problem of the low version?
drop PROCEDURE IF EXISTS ' dmu_exedynamicsql_bypage ';
delimiter;;
create definer= ' root ' @ '% ' PROCEDURE ' dmu_exedynamicsql_bypage ' (_qrysql Mediumtext, out _totalcount int)
begin
set @qrySql = _qrysql;
prepare stmt from @qrySql;
execute stmt;
deallocate prepare stmt;--Release preprocessing segment
Set _totalcount = 0;
Select Found_rows () into _totalcount;
END
;;
DELIMITER;
Note: DELIMITER; The meaning. Default semicolon in MySQL; Is the end of an execution, and the stored procedure contains multiple statements, semicolon intervals, which are executed together, how to solve the problem?
DELIMITER;; Tell MySQL to execute the following statement together until it encounters two semicolons;; After the above stored procedure executes, DELIMITER; Switch the delimiter to a single semicolon;
Limit in MySQL stored procedure