gpt4 book ai didi

mysql - mysql类别ID不明确

转载 作者:行者123 更新时间:2023-11-29 22:01:18 26 4
gpt4 key购买 nike

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 - mysql类别ID不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32621645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com