在運行以下程序:當最後一行被返回時,爲什麼我得到的結果包含多個行錯誤?
DELIMITER $$
DROP PROCEDURE IF EXISTS `portaldb`.`is_optional_type_assigned`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `is_optional_type_assigned`(userId int, optionalPlanId int)
begin
if userId is not null and optionalPlanId is not null then
// Will return multiple rows
select conv.FeatureName from planallocation as pa
left join subscriptioninfo as si
on si.SubscriptionId = pa.SubscriptionId
left join plans as pl
on pl.PlanId = pa.CurrentPlanId
right join conversiontable as conv
on conv.ConversionId = pl.OptionalFeatureId
where si.UserId = userId and
conv.FeatureType = 'optional' into @featureList;
// Will return single row
select conv.FeatureName from conversiontable as conv
right join plans as pl
on conv.ConversionId = pl.OptionalFeatureId
where conv.FeatureType = 'optional' and
pl.PlanId = optionalPlanId into @featureName;
if @featureName in (@featureList) then
select true as isAssigned;
else
select false as isAssigned;
end if;
end if;
end$$
DELIMITER ;
我越來越:
Error Code : 1172
Result consisted of more than one row
錯誤。這可能是什麼原因?前兩個select語句的結果被分配給變量,然後進行比較,如果一個集合包含另一個。
請問'如果@ (@featureList)'工作中的featureName?目前它不工作。 –
如果我建議的重組工作 - 第二個查詢會導致真/假結果,因此不需要「(@featureList)中的if @featureName」。 – PaulF