Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Counting foreign keys

Re: Counting foreign keys

From: <bhavinsh_at_my-deja.com>
Date: Fri, 29 Dec 2000 19:54:55 GMT
Message-ID: <92iq6c$s5i$1@nnrp1.deja.com>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US