Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2320395
  • 博文数量: 473
  • 博客积分: 12252
  • 博客等级: 上将
  • 技术积分: 4307
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-12 10:02
文章分类

全部博文(473)

文章存档

2012年(8)

2011年(63)

2010年(73)

2009年(231)

2008年(98)

分类: Mysql/postgreSQL

2009-06-02 12:41:02

摘自:
set @aSql="select count(id),sum(price) into @tclick,@todayTotalrom adnote where 1=1 ";
prepare sqlstmt from @aSql;
execute sqlstmt; 



你之后
select  @tclick;
或者赋给一个OUT 变量就可以了。
  1. #拼接查询总记录的SQL语句   
  2. set v_sqlcounts = concat('select count(*) into @recordcount from ',v_tables,v_where);   
  3. set @sqlcounts := v_sqlcounts;   
  4. #预处理动态SQL   
  5. prepare stmt from @sqlcounts;   
  6. #传递动态SQL内参数   
  7. set @s1= categoryid;   
  8. execute stmt using @s1;   
  9. deallocate prepare stmt;   
  10. #获取动态SQL语句返回值   
  11. set recordcount = @recordcount;  

以上我上再做存储过程分页里用到动态SQL里将查询到的count记录条数通过变量@recordcount放到recordcount里面了。

阅读(3691) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~