spawns 表中 有重复的数据 库  重复的字段是position_x 和 position_y  ID字段是排序的嘛就是 1234... 我想把 表 spawns 中  字段 position_x 和 position_y 一样的2条数据 删除一条就 行了.. 这句子怎么写呢 

解决方案 »

  1.   

    delete from spawns where exists (select position_x, position_y from spawns group by position_x,position_y having count(*) > 1) and not exists (select min(ID) from spawns group by position_x,position_y having count(*)>1);这样写哪里不对
      

  2.   

    ID   position_x  position_y     这和进字段
    1     2               3
    2     3               43     2                3
    position_x  position_y    重复的有 1和3行   要么删除第1行  要么删除第3行这样的语句怎么写.谢谢
      

  3.   

    ID就是标识一条记录的字段
    delete a from tt a left join b on a.position_x=b.position_x and a.id>b.id
      

  4.   

    delete a from yourTable a inner join yourTable b on a.position_x=b.position_x and a.position_y=b.position_y
    where a.id>b.id
      

  5.   

    delete from test where id not in (select * from (select min(id) from test group by userid,addtime) a);
      

  6.   

    保留ID最小那条:
    delete a from 表 a where not exists (select 1 from 表 b where b.position_x=a.position_x and b.position_y=a.position_y and b.id<a.id)