用exists查询表t表中a列的重复数据的sql语句该怎么写?
select*fromtwhereexists(select*fromt1wherea=a),这样写肯定不对,求大神指导。还有一个表中两列a,b相同数据的,select*...
select * from t where exists (select * from t1 where a=a),这样写肯定不对,求大神指导。还有一个表中两列a,b相同数据的,select * from t where exists (select * from t1 where a=b),这样写不对
展开
2个回答
展开全部
这样的数据,首先要有关键字,或是其他字段,能识别出列的数据重了,但数据不是同一行。
select * from t as t2
where exists (select 1 from t as t1 where t1.a=t2.a and t1.关键字 <> t2.关键字 )
同样的,要有能识别的关键字
select * from t as t2 where exists (select 1 from t as t1 where t2.a=t1.b and t1.关键字 <> t2.关键字 )
select * from t as t2
where exists (select 1 from t as t1 where t1.a=t2.a and t1.关键字 <> t2.关键字 )
同样的,要有能识别的关键字
select * from t as t2 where exists (select 1 from t as t1 where t2.a=t1.b and t1.关键字 <> t2.关键字 )
追问
没有关键字啊,只要是重复的都查询出来,不管他是什么内容
追答
select t.* from t,( select a from t group by a having count(1) > 1 ) b
where t.a = b.a
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询