Subject | Re: [firebird-support] Re: Old-style left join |
---|---|
Author | Kjell Rilbe |
Post date | 2005-03-08T21:10:50Z |
ainpoissee wrote:
you want.
Generically, this is what you need to do:
select MASTER.F1,
MASTER.F2,
...
MASTER.Fn,
DETAIL.F1,
DETAIL.F2,
...
DETAIL.Fm
from MASTER, DETAIL
where MASTER.PK = DETAIL.FK
union
select MASTER.F1,
MASTER.F2,
...
MASTER.Fn,
cast(null as <whatever>),
cast(null as <whatever>),
...
cast(null as <whatever>)
from MASTER
where not exists (
select 1
from DETAIL
where MASTER.PK = DETAIL.FK
)
Good luck,
Kjell
--
--------------------------------------
Kjell Rilbe
Adressmarknaden AM AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> Actually RTG.Vahetus is FK and yes, in the second part of the union INope. You're thinking in outer join terms. It won't work.
> want those records from RTG for which no matching Vah record exists
> (so RTG.Vahetus is NULL).
> Casting NULL as datatype as suggested byIt will avoid the error message you got, but you won't get the records
> Martijn and Chris seems to work.
you want.
Generically, this is what you need to do:
select MASTER.F1,
MASTER.F2,
...
MASTER.Fn,
DETAIL.F1,
DETAIL.F2,
...
DETAIL.Fm
from MASTER, DETAIL
where MASTER.PK = DETAIL.FK
union
select MASTER.F1,
MASTER.F2,
...
MASTER.Fn,
cast(null as <whatever>),
cast(null as <whatever>),
...
cast(null as <whatever>)
from MASTER
where not exists (
select 1
from DETAIL
where MASTER.PK = DETAIL.FK
)
Good luck,
Kjell
--
--------------------------------------
Kjell Rilbe
Adressmarknaden AM AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64