{"id":570,"date":"2010-04-21T21:57:12","date_gmt":"2010-04-21T21:57:12","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=570"},"modified":"2010-07-17T01:35:44","modified_gmt":"2010-07-17T01:35:44","slug":"how-to-remove-duplicate-entries-from-a-table","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2010\/04\/how-to-remove-duplicate-entries-from-a-table\/","title":{"rendered":"How to remove duplicate entries from a table ?"},"content":{"rendered":"<p>Removing Duplicate entries from Mysql database table are really simple. I have found some times interviewer ask tricky questions like this. PHP-MYSQL Beginners\u00a0 just be careful !<\/p>\n<p>It can all be done with three manual SQL steps! No PHP Coding required, and it works with MySQL 4 and above versions.<\/p>\n<p><strong>Step One<\/strong> &#8211; <\/p>\n<pre lang=\"sql\">\r\nCREATE TABLE MyNewTable as\r\nSELECT * FROM MyOldTable WHERE 1 GROUP BY [column to remove duplicates by];\r\n<\/pre>\n<p><strong>Step Two<\/strong> &#8211; You hate to keep old  table with all the duplicate entries, so drop it!<\/p>\n<pre lang=\"sql\">\r\nDROP TABLE MyOldTable;\r\n<\/pre>\n<pre lang=\"sql\">\r\nRENAME TABLE MyNewTable TO MyOldTable;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Removing Duplicate entries from Mysql database table are really simple. I have found some times interviewer ask tricky questions like this. PHP-MYSQL Beginners\u00a0 just be careful ! It can all be done with three manual SQL steps! No PHP Coding required, and it works with MySQL 4 and above versions. Step One &#8211; CREATE TABLE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[24],"tags":[],"class_list":["post-570","post","type-post","status-publish","format-standard","hentry","category-mysql-interview-questions"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":8,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":840,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/570\/revisions\/840"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}