检查重复的 mysql 行
我有一个 mysql 表,其中包含 field_one
、field_two
、field_third
我想检查 field_one 是否包含重复值(例如它是否是唯一的) 。
在mysql中如何做到这一点?
谢谢
I have a mysql table that contains field_one
, field_two
, field_three
I want to check if field_one contains a duplicate value (like if it was unique).
How to do that in mysql?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这将显示多次出现的
field_one
值:This will show you values for
field_one
that occur more than once:或者
or
如果您只需要检查一列中的所有值是否唯一,您可以使用它来计算所有唯一值:
...并将其与该列中所有值的数量进行比较:
这可能会消耗大量内存大桌子。
If you just need to check if all values are unique in one column, you could use this to count all unique values:
...and compare it to the the number of all values in the column:
This might consume a lot of memory on large tables.