簡體   English   中英

左聯接與子查詢

[英]Left join with sub query

不知道為什么在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 

您的問題是缺少ON子句。 此外,此邏輯不需要子查詢:

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

請注意,不匹配的行會將所有列設置為NULL

??? 對於應該用於JOIN任何列。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM