方法一:
select t1.* from table_name t1,table_name t2 where t1.a=t2.a and t1.b=t2.b and t1.c<>t2.c;
方法二:
select t1.* from table_name t1
inner join
(select a,b from table_name group by a,b having count(*)>1)
t2
on t1.a=t2.a
and t1.b=t2.b
在百度上查到的.
自己写的时候,第一种方法没想到第三个条件,
第二种方法没想到having.唉.
很多字段:字段A 字段B 字段C ... ...
A1 1 12
A1 2 24
A1 3 14
A1 4 47
A1 3 15
B2 1 45
... ... ...
查询结果: A1 3 14
A1 3 15
就是把 字段A和字段B分别都相同的记录查询出来
经过测试后发现只有方法2是对的,方法1有重复的值出现.不知道为什么.没空研究了.