Subject | Re: [ib-support] Re: Optimising an SQL Query Help |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-01-25T08:55:51Z |
Hi Colin,
from your original question (asked on Sunday, but I don't see any
answers) it doesn't seem to matter how many ObjectDs have status < 8,
just if there are any. So I would simply use something like
SELECT <WhateverYouWant>
FROM ObjectA
WHERE NOT EXISTS (
Select 1
FROM ObjectD
INNER JOIN ObjectC ON (ObjectD.ID = ObjectC.ID)
INNER JOIN ObjectB ON (ObjectC.ID = ObjectB.ID)
WHERE (
(ObjectB.Id = ObjectA.Id) AND (ObjectD.Status < 8))
EXISTS could be considerably faster than a COUNT.
HTH,
Set
from your original question (asked on Sunday, but I don't see any
answers) it doesn't seem to matter how many ObjectDs have status < 8,
just if there are any. So I would simply use something like
SELECT <WhateverYouWant>
FROM ObjectA
WHERE NOT EXISTS (
Select 1
FROM ObjectD
INNER JOIN ObjectC ON (ObjectD.ID = ObjectC.ID)
INNER JOIN ObjectB ON (ObjectC.ID = ObjectB.ID)
WHERE (
(ObjectB.Id = ObjectA.Id) AND (ObjectD.Status < 8))
EXISTS could be considerably faster than a COUNT.
HTH,
Set