mysql存储过程问题,请大家帮帮我

来源:互联网 发布:centos6.7本地网络配置 编辑:程序博客网 时间:2024/04/30 22:21
BEGIN


DECLARE userNames varchar(500) DEFAULT ''; ##用户名字
DECLARE sums int DEFAULT 0; 
DECLARE namess varchar(500) DEFAULT ''; 
DECLARE i int; 
set i = 0;
select count(*) into sums from book where price = 123;
##select name into namess from book where price = 123;##这个是错误的因为这条sql 返回的有多条数据

while i < sums 
DO
set i = i+1;
end while;
END


上述select 中  结果为:
id   name  price
1     aa     123
2     bb     123


我想把得到的多条数据中  name字段里的值拿出来拼成  aa,bb   这样的字符传  怎么做,请大家帮帮我.感激不尽
原创粉丝点击