开发者

Is it possible to do a 3 table join in MS-Access?

I try to do a 3-table join in Access and i开发者_C百科t will not work. Is it possible?


I once had a problem when I tried

select
  x,
  y
from 
  A        inner join
  B on k=l inner join
  C on f=g

This didn't work. But it works with parantheses:

select
  x,
  y
from ( 
  A          inner join
  B on k=l ) inner join
  C on f=g


All the various types of multi-table joins that are available in other flavour of SQL are permitted in MS-Access/Jet. For example, here's a straight three-table hierarchical example (a bit more real-world than the other answers here):

SELECT
    x.FirstName,
    x.Surname,
    r.RegionName,
    c.CountryName
FROM
    (Customer x LEFT JOIN Region r
    ON r.ID=x.RegionID)
    LEFT JOIN Country c
    ON c.ID=r.CountryID

Or did you want to know how to do it using the Visual Designer in MS-Access?


Yes, it's possible:

Select *
From A, B, C
Where A.a = B.b
And A.c = C.c

or

Select *
From A, B, C
Where A.a = B.b
And B.c = C.c


Access can do most types of joins (apart from a full outer) I wonder with your 3 table join if you are doing an ambiguous outer join? Have a look at this KB article for an explanation

support.microsoft.com/kb/124937

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜