我有一个包含类别信息的表格。
该表有一个字段来标记父类别和子类别。
我试图通过查询列出父类别,然后列出其子类别。
我尝试了类似的东西
SELECT
CategoryID.categories as ParentID,
CategoryName.categories AS ParentName,
parents.*
FROM
categories AS parents LEFT JOIN categories AS child
ON child.Parent = parents.ParentID
但不幸的是,它对我不起作用。它给了我一个奇怪的错误。
[SQL] SELECT CategoryID.categories as ParentID, CategoryName.categories
AS ParentName, parents.* FROM categories as parents LEFT JOIN categories as child on child.Parent = parents.ParentID
[Err] 1054 - Unknown column 'CategoryID.categories' in 'field list'
我确信所有字段名称都是正确的。