Posts Tagged ‘mysql’

Find Duplicates in MySQL

No Comments »

Useful SQL Query for finding duplicates in your database. It helps to sort Unique Key problem.

SELECT id, count( * ) AS n
FROM [table_name]
GROUP BY id
HAVING n >1

And another one for replacing strings. Useful if you dont want international characters in your database field

UPDATE [table_name]
SET [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');