所以伙计们,我正在尝试实现嵌套集模型,我有以下查询
SELECT
n.CategoryID,
CategoriesI18n.CategoryName,
COUNT(*)-1 AS level FROM Categories AS n,
Categories AS p LEFT JOIN CategoriesI18n ON (
n.CategoryID=CategoriesI18n.CategoryID AND CategoriesI18n.Locale="en-US"
) WHERE n.lft BETWEEN p.lft AND p.rgt GROUP BY n.lft ORDER BY n.lft;
当我选择树时,我必须加入 CategoriesI18n 表,这是当前类别的多语言行。但我得到这个错误
Unknown column 'n.CategoryID' in 'on clause'
我不知道为什么。也许 Categories AS p 会覆盖第一个别名?