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

后端 未结 4 1535
别那么骄傲
别那么骄傲 2020-12-20 06:10

I try to do a 3-table join in Access and it will not work. Is it possible?

相关标签:
4条回答
  • 2020-12-20 06:41

    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?

    0 讨论(0)
  • 2020-12-20 06:42

    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
    
    0 讨论(0)
  • 2020-12-20 06:45

    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 讨论(0)
  • 2020-12-20 06:47

    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
    
    0 讨论(0)
提交回复
热议问题