查询有2个以上X:
select * from 表 where X in
(
select X from 表
group by X
having count(X) > 1
)
查询X,Y,Z有2个以上:
select * from 表 where X in ( select X from 表 group by X having count(X) > 1)
union
select * from 表 where Y in ( select Y from 表 group by Y having count(Y) > 1)
union
select * from 表 where Z in ( select Zfrom 表 group by Z having count(Z) > 1)
你的意思是多条记录X Y Z 的值一样?
比如这样
X Y Z
1 2 3
1 2 3
1 1 1
1 1 1
select x,y,z,count(*) from tablename group by x,y,z having count(*)>1
楼主的意思是要查找X、Y、Z都相同的记录吧?
select X,Y,Z from 表名 group by X,Y,Z having count(*)>1