表单是这样 no name age
1 ll 18
2 mm 18
3 kk 17
4 qq 16
我想查一下重复的age即显示1 ll 18
2 mm 18
可是我用这样的语句应该没错啊
select*
from table
where age in
(select age
from table
group by age
having count(age)=2)
可是总是报错,ERROR 1064
1 ll 18
2 mm 18
3 kk 17
4 qq 16
我想查一下重复的age即显示1 ll 18
2 mm 18
可是我用这样的语句应该没错啊
select*
from table
where age in
(select age
from table
group by age
having count(age)=2)
可是总是报错,ERROR 1064
另外建议贴出你实际的语句。否则table是关键字 `table`
inner join
(select age,max(no) as ma from table group by age having count(age)=2) b
on a.age=b.age and a.no=b.ma
select a.no,a.name,a.age from test a
left join test b on a.age=b.age and a.no>=b.no
group by a.no,a.name,a.age
having count(b.age)>=2
对。版本不支持。没什么好办法。只能这样处理了select a.no,a.name,a.age
from tableName a inner join tableName b on a.age=b.age
group by a.no,a.name,a.age
having count(*)>1
select*
from table group by age having count(*)>2