我有以下内容: 表(字段名称)
有效(activeID,activeName)
ActiveCategories(activeID,categoryID)
分类(的categoryID,类别名)
我希望查询结果在ActiveCategories上获取Active的Left Join,但不是CategoryID [来自ActiveCategories] Integer它应该显示相应的categoryName [来自Categories]。 直到现在我已设法显示整数但不是相应的名称。
答案 0 :(得分:0)
尝试:
选择a.activeID,a.activeName,d.categoryName
from Active a
left join (select b.activeID activeID, c.categoryName CategoryName
from ActiveCategories b
left join Categories c on b.categoryID = c.categoryID) d
on a.activeID = d.activeID
答案 1 :(得分:0)
select a.activeID, a.activeName, c.categoryName
from Active a
left outer join ActiveCategories b on a.activeID = b.activeID
left outer join Categories c on b.categoryID = c.categoryID