Sharada
Sharada

Reputation: 75

How to write this nested query?

Here are 2 queries. Which one is correct?

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'.

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.

Upvotes: 1

Views: 565

Answers (1)

p.campbell
p.campbell

Reputation: 100567

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;

Upvotes: 2

Related Questions