请教一个查询问题
一个users表,有三个字段codeid name userid codeid是主键,我想找出相同name但是userid多于1的记录?怎么查询?select userid from userswhere count(select userid from usersgroup by name )> 1这样会报错?高手帮我改正下,谢谢.
[解决办法]
如果要查所有的信息
Select * from userswhere Where name In (select name from userswhere group by name Having Count(userid)> 1)
[解决办法]
select name userid from tb group by name userid having count(*) > 1
[解决办法]
select userid from usersgroup where name in (select name from usersgroup group by name having count(1)> 1 )