user656925
user656925

Reputation:

deleting duplicates

From this SO POST Finding Duplicates, how can I delete duplicates.

SELECT firstname, lastname, list.address FROM list 
INNER JOIN (SELECT address FROM list 
GROUP BY address HAVING count(id) > 1) dup ON list.address = dup.address 

Upvotes: 0

Views: 766

Answers (1)

Code Monkey
Code Monkey

Reputation: 319

just use the DISTINCT keyword:

SELECT DISTINCT firstname FROM list;

if any of the output is a duplicate, mysql will remove them.

for more documentation on DISTINCT go here:

http://www.cyberciti.biz/faq/howto-removing-eliminating-duplicates-from-a-mysql-table/

Upvotes: 1

Related Questions