您的位置:首页 > 数据库 > MySQL

Mysql 如何删除数据表中的重复数据!

2014-06-11 09:10 260 查看
1、使用distinct查询所有不重复的记录

2、创建数据表相同结构的临时表,将第一步的数据复制进去

create temporary table if not exists student_temp as (select distinct(name), sex from student);

3、truncate table student;

4、insert into student(id,name,sex) select null,name,sex from student_temp;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: