查数据:
  select count(num), max(name) from student --列出重复的记录数,并列出他的name属性 
  group by num 
  having count(num) >1 --按num分组后找出表中num列重复,即出现次数大于一次 
删数据:
  delete from student 
  group by num 
  having count(num) >1
  这样的话就把所有重复的都删除了。 查询语句没有问题,但删除语句执行不了!~~附近有语法错误

解决方案 »

  1.   

    delete from student a join (select num from student group by  num having count(num) >1)b on a.num=b.num
      

  2.   

    delete a from student a where exists(select 1 from student where num=a.num and name<>a.name)
      

  3.   

    delete from student where num in (select num from student group by num having count(1) > 1)
      

  4.   

    delete from student 
    where num in (select num from student group by num having count(*) > 1)