Thursday, November 17, 2011

Some Duplicates in Mysql

 

Some useful tips for Duplicates in Mysql
To findout the duplicate entries(Name) in a table
SELECT Name, count(id) as cnt FROM list GROUP BY Name HAVING cnt > 1

While insert operation if we got the primary key already exist then we can update the row as
Insert into list (Name,address) values('xxx','yyy') on duplicate update Name='xxx'

No comments:

Post a Comment