Equilevant of Oracle for optional records
- From: "Maurice W. Darr" <mdarr@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 19:17:53 -0500
Any or all,
The Oracle syntax for outer joins makes it possible to join to a table by
record type but I cannot find an equilivent in Access. Here's what I mean.
I have two tables
T1 (id)
T2 (id,type,data)
I want a join that will return several records from T2 joined to T1 but
with different Type values
In Oracle this is straigthforward.
Select t1.id,ta.data a_data,tb.data b_data
from t1, t2 ta,t2 tb
where ta.id+=t1.id
and ta.type+="A"
and tb.id+=t1.id
and tb.type+="B"
This query will return all the records in T1. If there is a corresponding
record in T2 with a type of 'A' it will return a record otherwise it will
return null in a_data. The same is true of b_data. Either a null if there
are no records with a 'B' or a value.
In Access I cannot find a way to do this in Access.
It would be nice to use
T1 LEFT JOIN T2 AS Ta ON T1.ID = Ta.CAPID and ta.type='A'
This does not work.
A straight left join with a filter by type will not return any records if
there is at least one alternate type in T2 for the join key.
Any ideas?
TIA, maurice
.
- Follow-Ups:
- Re: Equilevant of Oracle for optional records
- From: Michel Walsh
- Re: Equilevant of Oracle for optional records
- From: Tom Ellison
- Re: Equilevant of Oracle for optional records
- Prev by Date: Re: Calcuate Elapse Time
- Next by Date: Re: how do I create a database using post code
- Previous by thread: Re: How to write query for sorting data in table using VBA?
- Next by thread: Re: Equilevant of Oracle for optional records
- Index(es):