Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql Select count of Child Keys
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01461951
Message ID:
01461953
Vues:
46
Hi Borislav. Thanks fro replying.
I know, in an ideal world this should not be the case, but I wanted to cover all eventualities, in case there were any
orpjaned childen
Regards,
Gerard

>>I have two tables, one is a child of the other.
>>Is there one Sql Statement that will give me a count of the child records for each Primary Key
>>e.g.
>>Parent Table
>>A
>>B
>>C
>>--------------------------------
>>Child Table
>>A XX
>>A VVV
>>A GDS
>>B HH
>>B UYU
>>D aaaa
>>-----------------------------
>>Result would be
>>A 3
>>B 2
>>C 0
>>D 1
>>
>>Tia
>>Gerard
>
>
>SELECT Parent.PK, ISNULL(COUNT(*), 0) AS ChildRecords
>FROM Parent
>LEFT JOIN Child ON Parent.PK = Child.FK
>GROUP BY Parent.PK
>
>
>BTW How did you have a Child records iof the Parent record did not exists?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform