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含糊不清 - 请问为什么?
答案 0 :(得分:0)
因此,您必须使用表的别名来解决此问题。因此您的查询将如下所示:
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 ;