我有 stockcards 和 stockcategories 表。
我想显示类别并显示在此类别下打开了多少张股票卡。
SELECT a.stockCatID, a.stockCatName, f.nProductsInside
FROM stockcategories a
LEFT JOIN
(
SELECT COUNT(b.stockID) AS nProductsInside
FROM stockcards b
)
f ON a.stockCatID = f.stockCatID
好吧,它返回#1054 - Unknown column 'f.stockCatID' in 'on clause'
显然我犯了一个错误..