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

 

 

posted on 2017-11-08 16:43  D-Z-K  阅读(1307)  评论(0编辑  收藏  举报

导航