How do I remove duplicate data or rows from a MySQL query?
If output from a MySQL query contains duplicate data or row and if you would like to remove the same use DISTINCT.
DISTINCT combined with ORDER BY needs a temporary table in many cases. Consider following query:
mysql> SELECT firstname FROM registration;
If you need unique firstname i.e remove duplicate contains type the command:
mysql> SELECT DISTINCT firstname FROM registration;
You can use DISTINCT with multiple column as follows:
mysql> SELECT DISTINCT firstname, city FROM registration;