Finding duplicate values in a MySQL database
In the following query, we list all lastname held by 2 or more employees.
SELECT lastname, COUNT(*) c FROM employees GROUP BY lastname HAVING c > 1;
If you don't want a value to unique, you should add a unique constraint to the column. However, you would from time to time have to deal with a badly designed database.