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!
Posted by Jamie Munro | February 27, 2012 | Tags: MySQL
This is an excellent little trick that will save some processing time by a server-side language having to loop through the data to achieve the same result. In this article, I am going to demonstrate how you can merge multiple rows into one field separated by a specific character.
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.