CREATE DEFINER=`sqladmin`@`%` PROCEDURE `sp_getContainerSize`(IN P_ProjectId INT, IN P_CategoryName VARCHAR(45))
BEGIN
SELECT ContainerName,LocationPath,ContainerDesc,ContainerSize,categoryId, ContainerUsed,ContainerSize-ContainerUsed as free,concat(round(100*((ContainerSize-ContainerUsed)/ContainerSize ),2), '%') as PercentageFreeContainer
FROM Container
inner join Location on Container.locationId=Location.locationId
where projectID=P_ProjectId;
END
它说我的categoryId不明确-请问为什么?
最佳答案
因此,您必须为表使用别名来解决此问题。因此,您的查询将如下所示:
SELECT a.ContainerName,a.LocationPath,a.ContainerDesc,
a.ContainerSize,a.categoryId,a.ContainerUsed,a.ContainerSize-a.ContainerUsed as free,
concat(round(100*((a.ContainerSize-a.ContainerUsed)/a.ContainerSize ),2), '%')as PercentageFreeContainer
FROM Container a
inner join Location b on a.locationId=b.locationId
where a.projectID=P_ProjectId ;
关于mysql - 类别ID不明确的mysql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32621645/