先分组,然后查询分组中数据数量大于1的数据即可:
select user_id from contacts where user_id in (select user_id from contacts group by user_id having count(*) > 1)
先分组,然后查询分组中数据数量大于1的数据即可:
select user_id from contacts where user_id in (select user_id from contacts group by user_id having count(*) > 1)