报错:Result consisted of more than one row
写了一个函数:
参数 : `product_type` int,`app_id` bigint
返回: varchar(64)
BEGIN
#Routine body goes here...
declare typeName varchar(64);
select name into typeName from t_b_product_type where product_type = `product_type` and app_id = `app_id` ;
RETURN typeName;
END
报错:Result consisted of more than one row 。我看了下测试数据,只有一条符合上面的查询条件,不可能有多条记录。
修改为:
在select into 语句末尾添加 limit 1. 就能正常执行
或者给表添加别名,也能得到正确结果,
BEGIN
#Routine body goes here...
declare typeName varchar(64);
select name into typeName from t_b_product_type as a where a. product_type = `product_type` and a.app_id = `app_id` ;
RETURN typeName;
END
请教各位,这是什么情况。