No more must you think about how to find a clean way to delete duplicate records in your database table. The following article will provide a single SQL query that will delete rows that are duplicated in your table. Before you begin, be sure you’ve tracked down the bad code that is causing this; otherwise, you will need to run it multiple times!
Whenever you need to display “random” data, it is always so tempting to take the simplest solution, e.g. SELECT * FROM mytable ORDER BY RAND(). This of course works perfectly; however, if your database table contains a lot of records (10,000+) a query like this can take seconds to complete – instead of 1/10th of a second. With a bit of extra effort and careful thought, this process can be improved and still provide truly random results.