在sqlite中查找重复的列值 [英] Find duplicate column value in sqlite
本文介绍了在sqlite中查找重复的列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表 DataTab
中插入了一些值。
I have inserted some values in the table DataTab
.
SomeId: Integer => Autogenerated primary key.
DataId: Guid
DataNumber: Integer
DataType: varchar
如果表包含重复的 DataId
值,以上就是我表中的列。
我已经使用数据库很长时间了。现在,我可以找出简单的查询了。但是我发现这有些困难。
The above are the column's in my tables, I want to find, if the table contains Repeated DataId
values.
It has been long time I had worked with databases. Now I can figure out simple queries. But I found this some what difficult.
我尝试了以下查询,这正确吗?
I tried the following query, is this correct?
SELECT * from (Select * from DataTab) AS X
where DataId= X.DataId AND SomeId!=X.SomeId
推荐答案
SELECT DataId, COUNT(*) c FROM DataTab GROUP BY DataId HAVING c > 1;
这篇关于在sqlite中查找重复的列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文