删除重复项 [英] deleting duplicates

查看:56
本文介绍了删除重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从这个 SO POST 查找重复项,我如何删除重复项.

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 

推荐答案

只需使用 DISTINCT 关键字:

just use the DISTINCT keyword:

SELECT DISTINCT firstname FROM list;

如果有任何输出重复,mysql 将删除它们.

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

有关 DISTINCT 的更多文档,请访问此处:

for more documentation on DISTINCT go here:

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

这篇关于删除重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆