你好,我想要以下内容(不使用子查询):
select planName where period=1 as 1stPlan
select planName where period=2 as 2ndPlan
select planName where period=3 as 3ndPlan
...
FROM plan inner join project ON Project.Id=Plan.ProjectId
谢谢
答案 0 :(得分:2)
select
plan1.planName,
plan2.planName,
plan3.planName
FROM project
left join plan plan1 ON Project.Id=Plan1.ProjectId and Plan1.period=1
left join plan plan2 ON Project.Id=Plan2.ProjectId and Plan2.period=2
left join plan plan3 ON Project.Id=Plan3.ProjectId and Plan3.period=3