我正在更新使用旧结构进行外部连接(=* 和 *=)的查询。我有 3 个表需要包含在外部联接中。
原始查询是:
SELECT s.SkillID ,
NULL AS Signature ,
NULL AS DPL ,
CASE WHEN ISNULL(ds.DPL, dg.DPL) IS NULL
THEN p.ScaleTo - p.ScaleFrom + 1
ELSE ISNULL(ds.DPL, dg.DPL)
END AS DefaultDPL
FROM tbJobs j ,
tbSkills s
INNER JOIN tbSkillGroups sg ON s.SkillGroupID = sg.SkillGroupID ,
tbPerfScales p ,
tbDPLs ds ,
tbDPLs dg
WHERE j.JobID = 866
AND ( ds.LevelID=*j.LevelID
AND ds.IDType = 1
AND ds.GroupOrSkillID=*s.SkillID
)
AND ( dg.LevelID=*j.LevelID
AND dg.IDType = 0
AND dg.GroupOrSkillID=*sg.SkillGroupID
)
AND ( ( s.PerfScaleID IS NOT NULL
AND p.PerfScaleID = s.PerfScaleID
)
OR ( s.PerfScaleID IS NULL
AND p.PerfScaleID = sg.PerfScaleID
)
)
我正在做:
SELECT s.SkillID ,
NULL AS Signature ,
NULL AS DPL ,
CASE WHEN ISNULL(ds.DPL, dg.DPL) IS NULL
THEN p.ScaleTo - p.ScaleFrom + 1
ELSE ISNULL(ds.DPL, dg.DPL)
END AS DefaultDPL
FROM tbPerfScales p ,
tbSkills s
INNER JOIN tbSkillGroups sg ON s.SkillGroupID = sg.SkillGroupID ,
tbJobs j
LEFT OUTER JOIN tbDPLs ds ON j.LevelID = ds.LevelID
AND s.SkillID = ds.GroupOrSkillID
LEFT OUTER JOIN tbDPLs dg ON j.LevelID = dg.LevelID
AND sg.SkillGroupID = dg.GroupOrSkillID
WHERE j.JobID = 866
AND ds.IDType = 1
AND dg.IDType = 0
AND ( ( s.PerfScaleID IS NOT NULL
AND p.PerfScaleID = s.PerfScaleID
)
OR ( s.PerfScaleID IS NULL
AND p.PerfScaleID = sg.PerfScaleID
)
)
出于某种原因,我收到了错误:
无法绑定多部分标识符“s.SkillID”。
我知道在这部分:
tbJobs j
LEFT OUTER JOIN tbDPLs ds ON j.LevelID = ds.LevelID
AND s.SkillID = ds.GroupOrSkillID
我不确定我做错了什么。
感谢任何帮助。何塞