Subject | Re: [firebird-support] Re: Efficiently find records from a self join without children records or a field=1 |
---|---|
Author | Milan Babuskov |
Post date | 2009-06-22T10:07:10Z |
Bhavbhuti Nathwani wrote:
SELECT iID, cDecs
FROM mItems m
WHERE lExcisable = 1 OR not exists(
select 1
from mItems d
where d.iPID = m.iID)
HTH
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com
> This is what I have created, can it be made better?Try:
> SELECT mItems.iID, mItems.cDesc
> FROM mItems
> WHERE (mItems.iID NOT IN (SELECT DISTINCT mParent.iID
> FROM mItems mChild
> JOIN mItems mParent
> ON mParent.iID = mChild.iPID))
> OR mItems.lExcisable = 1
SELECT iID, cDecs
FROM mItems m
WHERE lExcisable = 1 OR not exists(
select 1
from mItems d
where d.iPID = m.iID)
HTH
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com