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
IIS host header and DNS
Spring Webflow snapshots occupy too much memory.
verifying port forwarding for your router failed
Attempting to move /tmp directory to another partition.
How would I see what people are downloading and how would I inject RST packets?
Skype ID creation date?
Send emails using listed, jquery
Microsoft ebs security server configuration
Socket Question
WordPress FIle Manager w/ Database Integration