摘自:
set @aSql="select count(id),sum(price) into @tclick,@todayTotalrom adnote where 1=1 ";
prepare sqlstmt from @aSql;
execute sqlstmt;
你之后
select @tclick;
或者赋给一个OUT 变量就可以了。
- #拼接查询总记录的SQL语句
- set v_sqlcounts = concat('select count(*) into @recordcount from ',v_tables,v_where);
- set @sqlcounts := v_sqlcounts;
- #预处理动态SQL
- prepare stmt from @sqlcounts;
- #传递动态SQL内参数
- set @s1= categoryid;
- execute stmt using @s1;
- deallocate prepare stmt;
- #获取动态SQL语句返回值
- set recordcount = @recordcount;
以上我上再做存储过程分页里用到动态SQL里将查询到的count记录条数通过变量@recordcount放到recordcount里面了。
阅读(3722) | 评论(0) | 转发(0) |