如何编写这个嵌套查询?

时间:2022-09-28 14:33:30

Here are 2 queries. Which one is correct?

这是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);

Error: Incorrect syntax near the keyword 'AND'.

错误:关键字“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);

Error: The multi-part identifier " Sem. SemRoleId" could not be bound.

错误:无法绑定多部分标识符“Sem.SemRoleId”。

1 个解决方案

#1


2  

Try this:

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;

#1


2  

Try this:

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;