注意我用的mysql数据库一个表中,我要保留num最大的50条数据  其余的删除   如何写这个删除命令

解决方案 »

  1.   

    delete a from a left join (select num from a order by num desc limit 50) b
    on a.num=b.num where b.num is null
      

  2.   

    delete from yourTable a where id not in (select id from yourTable order by num desc limit 50)
      

  3.   

    delete from tb a where id not in(select id from tb order by num desc limit 50);
      

  4.   

    你测试过没有,1楼代码在MYSQL 5.5下测试通过