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
server name
HP SAN drive fail
Which Exchange Cert for iPhones
WCF Problem: The private key is not present in the X.509 certificate.
When ActiveX control on form changes, apply new value to another control on form.
Windows XP - BSOD STOP: C000021a The windows logon process terminated unexpectedly with a status of 0x00000005 (0x00000000 0x00000000)
Unable To Add Outlook Account
Two SCCM primary site in active directory
Windows Server 2008 R2 iSCSI Initiator and HP D2D CHAP issue
Store file in mysql using connector.net and blob field