如何將表加入到多個表中?這樣的事情,我們可以很容易做到在SQLEF4如何將表加入兩個或多個其他表
SELECT p.* FROM Person.BusinessEntity AS e
INNER JOIN Person.Person AS p ON e.BusinessEntityID = p.BusinessEntityID
AND e.BusinessEntityID = p.BusinessEntityID INNER JOIN Person.BusinessEntityContact AS b
ON e.BusinessEntityID = b.BusinessEntityID AND p.BusinessEntityID = b.PersonID
在此先感謝
查看本頁上的最後一個示例:http://msdn.microsoft.com/en-us/library/bb896266.aspx – kol
是的,它顯示瞭如何在兩個表之間進行連接,以及msdn還有兩個連接示例字段,但僅限於另一個表。我需要使用兩個其他表,如「INNER JOIN Person.BusinessEntityContact AS b ON e.BusinessEntityID = b.BusinessEntityID AND p.BusinessEntityID = b.PersonID」 – Bhuvan
請參閱此答案:http://stackoverflow.com/questions/1264993/linq-left-join-on-multiple-or-conditions或基本上連接使用一個新的對象進行比較'在新的{e.BusinessEntityID,p.BusinessEntityID}的Person.BusinessEntityContact中加入b等於new {b.BusinessEntityID ,b.PersonID}' –