Posted by noone on 02/13/06 05:36
Domestos wrote:
> "Mick" <mickoc@gmail.com> wrote in message
> news:1139788418.350629.281030@g14g2000cwa.googlegroups.com...
>
>>Hi all,
>>
>>I am trying to construct a sql query which will retrieve the group name
>>and
>>number of people in each group from the below table structure
>>
>>sms_people
>>- member_id
>>- member_name
>>- member_lastname
>>- member_number
>>- member_region
>>
>>sms_people_groups
>>- group_id
>>- member_id
>>
>>sms_groups
>>- group_id
>>- group_name
>>- group_description
>>
>>All i have available to search on is the group_id. I'm having trouble
>>retrieving the group_name and the number of members it contains as they
>>are in separate tables..
>>
>>Any help much appreciated,
>>
>>Cheers,
>>Michael
>>
>
>
> SELECT group_name FROM sms_groups WHERE group_id='xxx'
> SELECT COUNT(member_id) FROM sms_people_groups WHERE group_id='xxx'
select a.group_name, count(b.member_id)
from sms_groups a ,sms_people_groups b
where a.group_id='xxx' and b.group_id=a.group_id
group by group_name
>
> These are the SQL statments and some work will be required to pass it into
> PHP.
>
>
[Back to original message]
|