Hi, I'm Danijel. I'm a front-end (html5, jquery) & back-end (php,mysql) developer with the passion to optimize my everyday life. I also love to pick around in ubuntu servers using nothing but root.
Let's say I'll be posting various things, some weird, some stupid, some just posts with random code. This is to simply to have everything stored in a place where I/YOU/WE can reuse ideas/solutions that I stumbled upon during my life as a developer.
Monday, November 26, 2012
MySQL Delete dupes
My favorite way of deleting dupes (taken from the honorable #mysql on freenode)
If you have a unique ID and the name may contain duplicates then
DELETE t1 FROM table1 AS t1 JOIN table1 AS t2 ON t1.id>t2.id AND t1.name=t2.name;
If you have other fields that need to be taken into consideration extend the join as needed. If it fails on a myisam table see http://bugs.mysql.com/bug.php?id=28837