Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Counting foreign keys
Thanks, but how do I also get the counts of 0. This only returns counts > 0.
Basically I'm trying to delete entries from tablea that don't have any child records in tableb.
In article <3a4c6142_at_ns.baltros.ru>,
"Sergey Gerasimov" <gsa_at_baltros.ru> wrote:
> >
> > TABLEA
> > (
> > pk
> > )
> >
> > TABLEB
> > (
> > pk2
> > fk REFERENCES TABLEA(pk)
> > )
>
> select tablea.pk, count(tableb.pk2)
> from tablea, tableb where tablea.pk = tableb.pk (+) group by tablea.pk;
>
> --
> Regards
> Sergey Gerasimov
> gsa_at_baltros.ru
>
>
Sent via Deja.com
http://www.deja.com/
Received on Fri Dec 29 2000 - 13:54:55 CST