Subject | Re: Left Outer Join |
---|---|
Author | Svein Erling Tysvær |
Post date | 2006-04-19T11:52:33Z |
Hi Friedrich!
First, I'll change your query a little bit to make it more readable to
myself (word wrap etc.) ;o)
select
ma.abfallschluessel,
ma.unterschluessel,
ek.entsorger,
ek.projekt,
ep.teilobjekt,
ep.datum
from materialart ma
left outer join entsorgungskopf ek
on ma.abfallschluessel = ek.abfallschluessel
and ma.unterschluessel = ek.unterschluessel
left outer join entsorgungsposition ep
on ek.lfd_ent_kop_nr = ep.lfd_ent_kop_nr
where
ep.datum is null
or ep.datum between '01.04.2006' and '19.04.2006'
This will return all records that either have no matching link to
entsorgungsposition or the matching record in entsourgungsposition has
unknown datum or datum in the first part of April. If the datum is
different from this, that row is excluded. It will be the same in both
your databases, it is not configurable.
From your question (and similar questions on this list), I guess that
the query that you are looking for is:
select
ma.abfallschluessel,
ma.unterschluessel,
ek.entsorger,
ek.projekt,
ep.teilobjekt,
ep.datum
from materialart ma
left outer join entsorgungskopf ek
on ma.abfallschluessel = ek.abfallschluessel
and ma.unterschluessel = ek.unterschluessel
left outer join entsorgungsposition ep
on ek.lfd_ent_kop_nr = ep.lfd_ent_kop_nr
and ep.datum between '01.04.2006' and '19.04.2006'
The question you originally asked excluded entire rows with
inappropriate datum, the above query doesn't exclude the rows, just
the parts referring to entsorgungsposition.
Did I guess right?
Set
First, I'll change your query a little bit to make it more readable to
myself (word wrap etc.) ;o)
select
ma.abfallschluessel,
ma.unterschluessel,
ek.entsorger,
ek.projekt,
ep.teilobjekt,
ep.datum
from materialart ma
left outer join entsorgungskopf ek
on ma.abfallschluessel = ek.abfallschluessel
and ma.unterschluessel = ek.unterschluessel
left outer join entsorgungsposition ep
on ek.lfd_ent_kop_nr = ep.lfd_ent_kop_nr
where
ep.datum is null
or ep.datum between '01.04.2006' and '19.04.2006'
This will return all records that either have no matching link to
entsorgungsposition or the matching record in entsourgungsposition has
unknown datum or datum in the first part of April. If the datum is
different from this, that row is excluded. It will be the same in both
your databases, it is not configurable.
From your question (and similar questions on this list), I guess that
the query that you are looking for is:
select
ma.abfallschluessel,
ma.unterschluessel,
ek.entsorger,
ek.projekt,
ep.teilobjekt,
ep.datum
from materialart ma
left outer join entsorgungskopf ek
on ma.abfallschluessel = ek.abfallschluessel
and ma.unterschluessel = ek.unterschluessel
left outer join entsorgungsposition ep
on ek.lfd_ent_kop_nr = ep.lfd_ent_kop_nr
and ep.datum between '01.04.2006' and '19.04.2006'
The question you originally asked excluded entire rows with
inappropriate datum, the above query doesn't exclude the rows, just
the parts referring to entsorgungsposition.
Did I guess right?
Set
--- In firebird-support@yahoogroups.com, Friedrich Remmert wrote:
> The result from one database includes all records from materialart
> (as expected).
>
> The result from the customer database includes only those records
> from materialart where a matching entry is found.
>
> Is this different behavior configurable? Where?