Skip to content

Instantly share code, notes, and snippets.

@mks-m
Created July 18, 2012 14:44
Show Gist options
  • Save mks-m/3136605 to your computer and use it in GitHub Desktop.
Save mks-m/3136605 to your computer and use it in GitHub Desktop.
create table mc (id int, member varchar(3));
insert into mc values (1, 'abc'), (1, 'pqr'), (2, 'xyz'), (2, 'pqr'), (3, 'pqr'), (3, 'abc');
Select id,count(*) as total from mc group by id having total=(Select count(*) from mc where id=1);
-- Result:
-- +------+-------+
-- | id | total |
-- +------+-------+
-- | 1 | 2 |
-- | 2 | 2 |
-- | 3 | 2 |
-- +------+-------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment