- $sql = "SELECT g.id, g.name, count(i.id) gm
- FROM `group` g, group_member gm, item i
- WHERE g.uid = %d
- AND i.uid = %d
- AND i.unseen AND i.visible
- AND NOT i.deleted
- AND i.`contact-id` = gm.`contact-id`
- AND gm.gid = g.id GROUP BY g.id";
+ $sql = "SELECT g.id, g.name, count(i.id) count " .
+ "FROM `group` g, group_member gm, item i " .
+ "WHERE g.uid = %d " .
+ "AND i.uid = %d " .
+ "AND i.unseen AND i.visible " .
+ "AND NOT i.deleted " .
+ "AND i.`contact-id` = gm.`contact-id` " .
+ "AND gm.gid = g.id GROUP BY g.id";