Re: Multiple outer joins in access

From: John Spencer (MVP) (spencer4_at_comcast.net)
Date: 02/25/04


Date: Tue, 24 Feb 2004 19:57:57 -0500

Yes and No.

It depends on which tables are being joined to which tables.

Select <FieldList>
FROM (TableA LEFT JOIN TableB
 On TableA.PK = TableB.FK)
 LEFT JOIN TableC ON
 TableA.PK = TableC.PK

I think that will work. It is a matter of which fields you use in the join and
how you place the parentheses. In the query grid, you would be joining from
TableA to TableB and From TableA to TableC.

Patrick Ryan wrote:
>
> Can I have multiple outer (left) joins, joining 3 or more tables, in an
> Access SQL statement? If so, what is the syntax? A left join between 2
> tables is not a problem.
>
> I have a table with foreign keys to 4 other tables as well as its own data
> fields. The fields that hold the foreign keys may have valid long integer
> values (keys) or nulls. Therefore, I can't use inner joins. I want the SQL
> statement to return the data fields from the "join" table as well as the
> related values from the 4 tables via the foreign keys (if they exist).
>
> I can actually do this by making 5 separate SQL statement connected by a
> union statement. But I think this would take a big performance hit with a
> lot of data. I am currently handling the above problem with lookups on the
> application level. I'd prefer not though. Any ideas? Thanks.



Relevant Pages

  • Re: select *
    ... > I agree with a) and b), but not c), it might be a personal preference... ... FROM TableA ... JOIN TableB ON TableA.AID = TableB.AID ... JOIN TableC ON TableB.BID = TableC.BID ...
    (microsoft.public.sqlserver.server)
  • Re: select *
    ... yeah, got your point. ... > FROM TableA ... > JOIN TableB ON TableA.AID = TableB.AID ... > JOIN TableC ON TableB.BID = TableC.BID ...
    (microsoft.public.sqlserver.server)
  • Re: Tricky query...can it be done in a DTS?
    ... select TableA.*, ... left join TableB on (join condition) ... left join TableC on ...
    (microsoft.public.sqlserver.dts)
  • Re: Advanced query issue
    ... FROM tablea As a RIGHT JOIN tableb as b ... That assumes tableb has all the possible occurrence of the two ... I also used UNION ALL, ...
    (microsoft.public.access.queries)
  • Re: Eliminating a sub-select from a query
    ... INNER JOIN ... LEFT JOIN tableC ... > tableA a, ... > tableB b ...
    (microsoft.public.sqlserver.programming)