Microsoft
Software
Hardware
Network
Question : help with a query
hello,
i have two tables
sms_groups and sms_group_members
CREATE TABLE `sms_groups` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`teamID` INT(10) UNSIGNED NULL DEFAULT NULL,
`description` VARCHAR(75) NULL DEFAULT NULL,
`createDate` TIMESTAMP NOT NULL,
`cellNum` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `sg_1` (`teamID`),
INDEX `gcell` (`cellNum`)
)
CREATE TABLE `sms_group_members` (
`group_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`sms_contactID` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`group_id`, `sms_contactID`)
)
I am trying to do this query and in the query is a count of contacts in the group
this is what i initially tried but does not give correct results for a group with no members
select g.id, g.teamID, g.description, g.createDate, g.cellNum, count(*) mem_count
from sms_groups g LEFT JOIN sms_group_members m ON g.id = m.group_id
where g.teamID = 6
group by m.group_id order by g.description
I would appreciate any help
Answer : help with a query
try this
select g.id, g.teamID, g.description, g.createDate, g.cellNum, (select count(1) from sms_group_members m where g.id = m.group_id) mem_count
from sms_groups g
where g.teamID = 6
Random Solutions
asp.net I am trying to convert an html form into an aspx form or ? what ever. Need Help on how to to it.
Winzip 12 Backup Job Issues ?
paypal integration in asp.net /VB
Windows 7 - Windows could not be activated
find textbox and start div underneath it
C#, general purpose logging
VB6 end of support - consequences for practice
Active Directory DNS records issue
Export Access 2010 Report to CSV with Headers?
KB973544