2011-09-24 154 views
1

這裏有2個問題。哪一個是正確的?如何編寫這個嵌套查詢?

SELECT link.[xlink:Show]. 
     Location.[xlink:show], 
     link.[xlink:actuate], 
     Location.[xlink:actuate], 
    FROM Sem 
    JOIN Location AND 
     Link join Location ON 
     link. link_id = Location.link_id); 

錯誤:關鍵字'AND'附近的語法不正確。

SELECT link.[xlink:Show], 
     Location.[xlink:show], 
    link.[xlink:actuate], 
     Location.[xlink:actuate], 
     Sem.SemRole 
    FROM Sem, Link 
    JOIN Location ON link. link_id = Location.link_id); 

錯誤:無法綁定多部分標識符「Sem。SemRoleId」。

+0

這是SQL服務器,MySQL的沒有。 – Johan

回答

2

試試這個:

SELECT LI.[xlink:Show], 
     LI.[xlink:actuate], 
     LO.[xlink:show], 
     LO.[xlink:actuate], 
     S.SemRole 
FROM Sem AS S 
INNER JOIN Location AS LO ON S.SemRoleId = LO.SemRoleId 
INNER JOIN Link AS LI ON LI.link_id = LO.link_id; 
+0

謝謝...它的工作原理 – Sharada