左连接子查询

时间:2016-07-19 15:12:29

标签: sql sql-server

不确定为什么它会在t2处抛出错误。我正在尝试运行一个简单的SQL查询。 在MS-SQL上运行,错误消息显示t2'

附近的语法不正确
UPDATE t1

SET t1.EmpSubCompetency = t2.EmpSubCompetency,
    t1.Competency = t2.Competency,
t1.FileName = t2.FileName,
t1.Longitude = t2.Longitude,
t1.Latitude = t2.Latitude,
t1.SubAreaName = t2.Region,
t1.SectorTag=t2.SectorTagClassification

FROM dbo.STG_MyCompetencies t1

LEFT JOIN (select * from dbo.STG_EmployeeMaster where Act_Flg='Y') t2 

1 个答案:

答案 0 :(得分:1)

您的问题是缺少ON子句。此外,您不需要此逻辑的子查询:

FROM dbo.STG_MyCompetencies t1 LEFT JOIN
     dbo.STG_EmployeeMaster t2
     ON t1.??? = t2.??? AND
        em.Act_Flg = 'Y'

请注意,不匹配的行会将所有列设置为NULL

???适用于JOIN所用的任何列。