mysql数学函数存储过程 Result consisted of more than one row

时间:2022-11-26 10:09:36

贴上sql语句:

drop table if EXISTS testprocedure;
create table testprocedure(
id int auto_increment PRIMARY key,
price float
);
insert into testprocedure (price) values (1.1),(2.1),(3.4),(5.4),(11.2),(8.9);
create procedure getprocedureprice(
out zz float,
out zx float,
out zc float,
out zv int
)
BEGIN
select max(price) into zz from good;
select min(price) into zx from good;
select avg(price) into zc from good;
select FLOOR(price) into zv from good;
END


在调用的时候会出现“ Result consisted of more than one row”错误,这是因为floor()函数是将float数据转化为int数据,目标对象是整个列,所以在调用的时候会出现这样的问题。只要加上限制条件即可(limit)。

                                   mysql函数汇总