这个问题已经困扰了我一段时间,我希望有一些wiz可以帮助解决这个问题。我有一个包含三个级别类别的产品表(三个表)。我试图列出所有的产品是连接到最后一级(第三级)的类别。当在下面运行查询时,将列出产品表中的所有产品。
下面是SQL查询。
SELECT *
FROM Product
INNER JOIN Product_Category
ON Product.ProductCategoryID = Product_Category.ProductCategoryID
INNER JOIN Product_Sub_Category
ON Product_Category.ProductCategoryID = Product_Sub_Category.ProductCategoryID
INNER JOIN Product_Sub_Sub_Category
ON Product_Sub_Category.ProductSubCategoryID = Product_Sub_Sub_Category.ProductSubCategoryID
WHERE Product_Sub_Sub_Category.ProductSubSCategoryID = request.querystring发布于 2014-06-12 20:38:55
您需要在第二层加入SubCategoryId,在第三层加入SubSubCategoryId
SELECT *
FROM
Product
INNER JOIN Product_Category ON (Product.ProductCategoryID = Product_Category.ProductCategoryID)
INNER JOIN Product_Sub_Category ON (Product_Category.ProductSubCategoryID = Product_Sub_Category.ProductSubCategoryID)
INNER JOIN Product_Sub_Sub_Category ON (Product_Sub_Category.ProductSubSubCategoryID = Product_Sub_Sub_Category.ProductSubSubCategoryID)
WHERE
Product_Sub_Sub_Category.ProductSubSubCategoryID = (request.querystring)https://stackoverflow.com/questions/24193262
复制相似问题