SQL语法:同一个表中某两个字段相同的现实出来!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:42:06
表中有很多字段:字段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分别都相同的记录查询出来

谢谢了 急用啊!!!!!!!!!

select 表名.* from 表名
inner join
(select 字段A,字段B from 表名 group by 字段A,字段B having count(*)>1)
as a
on 表名.字段A=a.字段A
and 表名.字段B=a.字段B

select 字段1,字段2,count(*) from table group by 字段1,字段2 having count(*)>1;

试试

字段A的值=字段B的值?还是A 或者B中出现重复的数据!

select A,B from table_name group by A,B;

方法一:
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