试图让产品在树下几个层次......它不起作用。
选择Products
.* 从 Products
LEFT JOIN `Product_Categories` C
ON `Products`.`Category_ID` = C.`ID`
OR `Products`.`Sub_Category_ID` = C.`ID`
OR `Products`.`Sub_Category2_ID` = C.`ID`
LEFT JOIN `Product_Categories` C2
ON C.`ID` = C2.`Parent_ID`
LEFT JOIN `Product_Categories` C3
ON C2.`ID` = C3.`Parent_ID`
LEFT JOIN `Product_Categories` C4
ON C3.`ID` = C4.`Parent_ID`
LEFT JOIN `Product_Categories` C5
ON C4.`ID` = C5.`Parent_ID`
LEFT JOIN `Product_Categories` C6
ON C5.`ID` = C6.`Parent_ID`
WHERE `Products`.`Is_Master_Product` = 'Yes'
AND `Products`.`Is_Published` = 'Yes'
AND (`Products`.`Category_ID` = '29'
OR `Products`.`Sub_Category_ID` = '29'
OR `Products`.`Sub_Category2_ID` = '29')
GROUP BY `Products`.`Name`
ORDER BY `Products`.`Name` ASC