SELECT g.gid, g.name
FROM groups g, groupmembers gm
WHERE gm.memberId = 1 AND g.gid = gm.groupId
select
g.gid,
g.name
from groups g
inner join groupmembers gm ON gm.memberId = 1 AND g.gid = gm.groupId
select
g.name,
COUNT(gm.id) as CountGM
from groups g
inner join groupmembers gm ON gm.memberId = 1 AND g.gid = gm.groupId
group by g.name