mysql 删除表中重复数据留一条

create table dept(
   depno int(2),
   deptname varchar(30)
)

select * from dept limit 3,4

insert into dept values(12,'kang6')
/*删除重复数据
delete from dept where depno in (
select a.did from (select max(depno) as did from dept group by deptname having count(deptname) > 1) a)
*/

你可能感兴趣的:(mysql,重复,表,留取一条)