我对此有疑问
SELECT
CASE WHEN QuantityPart =< Threshold
THEN (Threshold - QuantityPart) + Threshold
END as RecommendedReorderQuantity, *
FROM parts, stock
有人可以帮忙吗?
SELECT *,
CASE WHEN QuantityPart =< Threshold
THEN (Threshold - QuantityPart) + Threshold
END as RecommendedReorderQuantity
FROM parts INNER JOIN stock
ON parts.PartID = stock.PartID
最佳答案
*
应该先出现在您的CASE
饱足感之前,另一件事是<=
不是=<
SELECT *,
CASE WHEN QuantityPart <= Threshold
THEN (Threshold - QuantityPart) + Threshold
END as RecommendedReorderQuantity
FROM parts, stock
作为附带说明,该查询产生笛卡尔积。如果这不是您想要的,则需要提供链接条件,例如
SELECT *,
CASE WHEN QuantityPart <= Threshold
THEN (Threshold - QuantityPart) + Threshold
END as RecommendedReorderQuantity
FROM parts INNER JOIN stock
ON parts.columnName = stock.columnName
其中
columnName
是定义它们之间关系的列。关于mysql - 选择案例不起作用#1064,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14764077/