简体   繁体   English

categoryID是模糊的mysql

[英]categoryID is ambigous mysql

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

It says my categoryId is ambiguous - may I ask why? 它说我的categoryId不明确-请问为什么?

So you have to use alias name for table to fix this problem. 因此,您必须使用表的别名来解决此问题。 hence your query will be like the following: 因此,您的查询将如下所示:

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 ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM