Subject Re: SQL for master-detail
Author Dan Cooperstock
--- In firebird-support@yahoogroups.com, "Ed Dressel" <Dressel@...>
wrote:
>
> I am looking for all of the master records that have one or no detail
> records.
>
> Select Master_ID from MasterInfo where Master_ID (select Master_ID
> from DetailInfo where [less then one record])
>
> Can this be done without a stored proc?

Sure:

Select * from MasterInfo m
where
(select count(*)
from DetailInfo d
where m.Master_ID = d.Master_ID) <= 1