I have 2 tables groups and contact and i fetch all groups with their total number of contact in contact table. Like in groups table i have values
group1 group2 in contact table i have
myname group1 myname1 group1 myname2 group1 now i want all groupname with their contact count like
group1 3 group2 0 i used :
SELECT g.gid,g.groupname,g.TYPE,g.DATE,COUNT(*)AS cnt,1 FROM groupname g,contacts c WHERE g.gid=c.gid AND uid=1 GROUP BY groupname But i got those group which have value.