我有一个mysql表,其中包含field_one、field_two、field_three
我想检查field_one是否包含重复的值(比如它是否是唯一的)。
如何在mysql中做到这一点?
谢谢
发布于 2011-06-03 00:07:36
这将显示多次出现的field_one的值:
select field_one, count(*) as Count
from MyTable
group by field_one
having count(*) > 1发布于 2011-06-03 00:11:45
select field_one from tblName where field_one like %'@field_one'%或
select field_one from tblName where field_one = @filed_one发布于 2021-02-22 03:50:12
如果您只需要检查一列中的所有值是否都是唯一的,则可以使用此命令来计算所有唯一值:
select Count(Distinct column) from table...and将其与列中所有值的数量进行比较:
select Count(column) from table这可能会消耗大型表上的大量内存。
https://stackoverflow.com/questions/6217100
复制相似问题