Subject | Re: [ib-support] Query Results problem |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-06-10T08:28:56Z |
Hi George,
At 11:19 09.06.2003 -0500, you wrote:
appearing on this list!
contained
not there is a matching record of D and E - and then in your WHERE-clause
you say that you should restrict returning to certain values of the same
tables. I think that in a LEFT [OUTER] JOIN, the only proper way to
restrict records of tables at the right side of the join is within the JOIN
criteria, not in the WHERE clause (I think I read it in some Interbase 5.6
documentation). Try changing your query to something like:
FROM
TALBEA A LEFT JOIN TABLEB B ON (A.FK1 = B.PK)
LEFT JOIN TABLEB C ON (A.FK2 = C.PK)
LEFT JOIN TABLEC D ON (A.FK3 = D.PK AND D.YETANOTHERFIELD IS NULL )
LEFT JOIN TABLEC E ON (A.FK4 = E.PK AND E.YETANOTHERFIELD IS NULL )
WHERE
A.PK = :ParameterizedPK
HTH,
Set
At 11:19 09.06.2003 -0500, you wrote:
> >you're hiding things from us.Yup, since I work in a cancer registry, I'm likely to use good ideas
>
>Trying not to, but being in the medical industry makes it hard for me to
>release
>actual statements.
appearing on this list!
>WHEREthis may be enough for us, at least considering that your original query
> A.PK = :ParameterizedPK AND
> D.YETANOTHERFIELD IS NULL AND
> E.YETANOTHERFIELD IS NULL
contained
>FROMIn your join you say that Firebird is to return records of A, whether or
> TALBEA A LEFT JOIN TABLEB B ON (A.FK1 = B.PK)
> LEFT JOIN TABLEB C ON (A.FK2 = C.PK)
> LEFT JOIN TABLEC D ON (A.FK3 = D.PK)
> LEFT JOIN TABLEC E ON (A.FK4 = E.PK)
not there is a matching record of D and E - and then in your WHERE-clause
you say that you should restrict returning to certain values of the same
tables. I think that in a LEFT [OUTER] JOIN, the only proper way to
restrict records of tables at the right side of the join is within the JOIN
criteria, not in the WHERE clause (I think I read it in some Interbase 5.6
documentation). Try changing your query to something like:
FROM
TALBEA A LEFT JOIN TABLEB B ON (A.FK1 = B.PK)
LEFT JOIN TABLEB C ON (A.FK2 = C.PK)
LEFT JOIN TABLEC D ON (A.FK3 = D.PK AND D.YETANOTHERFIELD IS NULL )
LEFT JOIN TABLEC E ON (A.FK4 = E.PK AND E.YETANOTHERFIELD IS NULL )
WHERE
A.PK = :ParameterizedPK
HTH,
Set