开发者

Find duplicate strings in database

开发者 https://www.devze.com 2023-01-29 16:03 出处:网络
I need to find all rows in my table where the strings of a specific field are duplicates in two or more places.

I need to find all rows in my table where the strings of a specific field are duplicates in two or more places.

Can that be don开发者_如何学JAVAe in a MySQL statment?

EDIT

I need to get every row not just a count of how many duplicates there are. I want to be able to edit the fields.


Yes, try something like this:

SELECT *
FROM `YourTable`
WHERE `YourColumn` IN (
    SELECT `YourColumn`
    FROM `YourTable`
    GROUP BY `YourColumn`
    HAVING COUNT(*) > 1
)


Yes, using GROUP BY and HAVING.

SELECT mycolumn, count(*) FROM mytable
group by mycolumn
having count(*) > 1
0

精彩评论

暂无评论...
验证码 换一张
取 消