1

I need to join multiple tables in access. Access has some odd syntax when it comes to joins, and I cant seem to get this right

In particular, C needs to consider fields from both A and B

 select a.*, B.*, c.* 
  from 
  (tblOne as A 
   Left join tblTwo as B on  A.ParentId = B.Id )
   left join tblThree as C on C.ParentId = B.Id and C.ShoeSize = A.ShoeSize

I have encountered and gotten past putting each Parens thing when more than 2 tables are involved. I can join in C as long as I only want to refer to 1 of the other tables. This type thing is fairly straight forward in SQL Server. Any help would be appreciated, I cant seem to find an answer on google.

The client is currently using ms Access 2003. If the problem can be remedied by a newer version, I am pretty I could talk them into an upgrade.

thanks

greg

4

1 回答 1

0

我刚刚在 Access 2010 中尝试了以下方法,它似乎有效,但我必须承认,我对如何在“现实世界”中使用它并没有清晰的认识......

SELECT ab.*, c.* 
FROM 
(
    SELECT a.ID AS ID1, a.ShoeSize AS ShoeSize1, b.ID AS ID2 
    FROM tblOne a LEFT JOIN tblTwo b 
        ON a.ParentId = b.Id
) ab LEFT JOIN tblThree c 
    ON c.ParentId = ab.ID2 and c.ShoeSize = ab.ShoeSize1
于 2013-04-24T19:44:44.870 回答