==========
A really easy way to do this is to add a UNIQUE index on the 3 columns. When you write the ALTER statement, include the IGNORE keyword. Like so:

ALTER IGNORE TABLE jobs ADD UNIQUE INDEX idx_name (site_id, title, company );

This will drop all the duplicate rows. As an added benefit, future INSERTs that are duplicates will error out. As always, you may want to take a backup before running something like this...

==========

Another possible solution that I've just come across:

DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name

if you want to keep the row with the lowest id value OR

DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name

if you want to keep the row with the highest id value.

I used this method in MySQL 5.1

Not sure about other versions.

*NB - You need to do this first on a test copy of your table!+ When I did it, I found that unless I also included AND n1.id <> n2.id, it deleted every row in the table.

==========

Add Unique Index on your table:

ALTER IGNORE TABLE `TableA`   
ADD UNIQUE INDEX (`member_id`, `quiz_num`, `question_num`, `answer_num`);

OR

Add primry key in your table then you can easily remove duplicates from your table using below query:

DELETE FROM member  
WHERE id IN (SELECT *
             FROM (SELECT id FROM member
                   GROUP BY member_id, quiz_num, question_num, answer_num HAVING (COUNT(*) > 1)
                  ) AS A
            );

==========

REF:

http://stackoverflow.com/questions/3311903/remove-duplicate-rows-in-mysql

http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql

http://stackoverflow.com/questions/14046355/how-do-i-delete-all-the-duplicate-records-in-a-mysql-table-without-temp-tables

MySQL 删除重复记录的更多相关文章

  1. mysql 删除重复记录语句

    mysql 根据条件删除重复记录 只保留最小id的重复数据 DELETEFROM newsWHERE news_id IN ( SELECT a.news_id FROM ( SELECT news_ ...

  2. Mysql删除重复记录,保留id最小的一条

    mysql 查询重复字段,及删除重复记录的方法MySQL, 数据库, 数据库, 字段, 服务器数据库中有个大表,需要查找其中的名字有重复的记录id,以便比较.如果仅仅是查找数据库中name不重复的字段 ...

  3. mysql删除重复记录语句的方法

    例如: id name value 1 a pp 2 a pp 3 b iii 4 b pp 5 b pp 6 c pp 7 c pp 8 c iii id是主键 要求得到这样的结果 id name ...

  4. MySQL删除重复记录只保留一条

    删除表中重复记录,只保留一条: delete from 表名 where 字段ID in (select * from (select max(字段ID) from 表名 group by 重复的字段 ...

  5. mysql删除重复记录,只保留最大ID的记录(非重复也保留)

    目前网上搜索的删除重复记录,大部分都是where子查询,本人感觉看上去不美观,故亲自手写了一个,如下: delete from mst_sku using mst_sku,(  select dist ...

  6. MySQL删除重复记录的方法

    参考网上的方法,总结了产出重复记录的方法,欢迎交流. 参考:http://www.cnblogs.com/nzbbody/p/4470638.html 方法1:创建一个新表临时储存数据 假设我们有一个 ...

  7. mysql删除重复记录语句,删除除了 id 号不同,其他都相同的学生冗余信息

    /** 在Mysql下执行: delete from my.stu where id not in( select min(id) id from my.stu group by code) ; 用途 ...

  8. mysql删除重复记录,保存Id最小的一条

    方法1:1.创建一个临时表,选取需要的数据.2.清空原表.3.临时表数据导入到原表.4.删除临时表.mysql> select * from student;+----+------+| ID ...

  9. Mysql 删除重复记录,只保留最小的一条

    delete from `jb_postcontent` where id not in(select min(id) from (select * from `jb_postcontent`) as ...

随机推荐

  1. 【推荐】CentOS安装Subversion-1.8.17+HTTP协议支持配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. 我们需要搭建一个自己的SVN服务器. 此外,搭建好的SVN服务器除了需要支持svn协议外,最好还需要支持HTTP协议和HTTPS协 ...

  2. 网络模型一般是指 OSI 七层参考模型和 TCP/IP 五层参考模型。

    网络模型一般是指 OSI 七层参考模型和 TCP/IP 五层参考模型. 每一层实现各自的功能和协议,并且都为上一层提供业务功能.为了提供这 种业务功能,下一层将上一层中的数据并入到本层的数据域中,然后 ...

  3. Zipline Risk and Performance Metrics

    Risk and Performance Metrics 风险和性能指标 The risk and performance metrics are summarizing values calcula ...

  4. python基础-第五篇-5.3装饰器

    小白发呆的看着窗外,同事们陆陆续续的地来到公司,想起算法,小白就飘飘然了.突然后面传来一声呼唤,原来是小刘! 小刘:不好意思啊!堵车了,就来晚了点,不耽误你的时间,咱们就开启的今天的培训内容吧! 小白 ...

  5. Fang Fang---hud5455(字符串处理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5455 就是求字符串中含有几个f[i], 输出最小的: 例如fff应该是2,有f[0]和f[1]组成的; ...

  6. 介绍importlib

    Python将importlib作为标准库提供.它旨在提供Pythonimport语法和(__import__()函数)的实现.另外,importlib提供了开发者可以创建自己的对象(即importe ...

  7. Linux touch命令

    touch命令不常用,一般用于更改文件时间戳,或创建一个空文件 命令选项 -a:只更改访问时间 -c:--no-create 不创建任何文件 -d:--date=字符串 使用指定字符串表示时间而非当前 ...

  8. Ignite缓存管理初体验

    Ignite缓存管理初体验:ignite服务端配置,大家可以用参考官方进行配置(或者使用默认配置也可以). 本文中的ignite使用版本是1.7,与spring结合使用.maven依赖配置 ignit ...

  9. R中的一些基础1106

    1.R中NA,NaN,Inf代表什么? NA:缺失数据 NaN:无意义的数,比如sqrt(-2) Inf:正无穷大 -Inf:负无穷大 2.确定一个数值型vector的第一个最值(最大/最小)的下标: ...

  10. C++学习笔记--友元

    C++控制对类对象私有部分的访问,在外部无法直接访问类的私有或保护成员.通常,公有类方法提供唯一的访问途径.有时这种限制太严格,不适合特定的编程问题.所以C++提供了友元这种形式,通过让函数或类成为类 ...