MYSQL存储过程获取记录总数

CREATE DEFINER = 'qtfrad'@'%'
PROCEDURE JiuHeng.GetRecordCount(in tablename varchar(800),in sCondition varchar(500),out counts int)
BEGIN

set @strSQL=concat('select count(1) from ',tablename);

set @strSQL=concat(@strSQL,' where ',sCondition);


prepare sqlstmt from @strSQL;

set counts = @strSQL;


execute sqlstmt;

select counts;

deallocate prepare sqlstmt;


END

原文地址:https://www.cnblogs.com/xiaoweigogo/p/7804860.html