select id, name from A where id in (select id from A group by id having count(id) >= 2) and name in (select name from A group by name having count(name)=1)
select * from aa where id in (select id from aa group by id having count(*)>1) and (id,name) not in (select id,name from aa group by id,name having count(*)>1);
在同一张表中,查询相同字段的数据,而另外字段不同数据,对吗? select * from biao a ,biao b where a.id!=b.id and a.name=b.name; name字段值相同,id字段值不同。
select * from table a ,table b where a.重复字段 = b.重复字段 and a.不重复字段 <> b.不重复字段
select * from table t where not exists(select * from table where t.fb_name=fb_name and t.fb_id>fb_id) 重复数据随便取一条。
select * From tab t1 where exists (select 1 from tab t2 where t2.字段1 = t1.字段1 and t2.字段2 <> t1.字段2);
select * from table a ,table b where a.重复字段 = b.重复字段 and a.不重复字段 <> b.不重复字段
select id, name from A
where id in (select id from A group by id having count(id) >= 2)
and name in (select name from A group by name having count(name)=1)
and (id,name) not in (select id,name from aa group by id,name having count(*)>1);
select * from biao a ,biao b where a.id!=b.id and a.name=b.name;
name字段值相同,id字段值不同。
where a.重复字段 = b.重复字段 and a.不重复字段 <> b.不重复字段
where a.重复字段 = b.重复字段 and a.不重复字段 <> b.不重复字段