Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A simple SQL but with the count of the child records
Message
 
 
To
20/08/2006 22:14:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01147165
Message ID:
01147174
Views:
18
This message has been marked as the solution to the initial question of the thread.
>I have a one to many relationship. From the master table, I am selecting all the records. But, for each record in the SQL result, I need to also include the number of child records. Anyone would have a quit example on how to achieve that?
select Master.*, step1.CountChildren from Master ;
inner join ;
(select MasterID, count(*) as CountChildren from Child group by masterID) step1 ;
on Master.MasterID = step1.MasterID
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform