刪除數據庫中的重復記錄
          SqlServer:
          delete from team where id in (select min(id) from team group by [name] having count(id) > 1)
          MySql:

          Error Code : 1064
          You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[name] having count(id) > 1)' at line 1
          (0 ms taken)

          so:

          create temporary table tmp_wrap select * from users_groups group by uid having count(1>= 1;

          truncate table users_groups;

          insert into users_groups select * from tmp_wrap;

          drop table tmp_wrap;

          OR:
          delete team as a from team as a,(select min(id) as id,`name` from team group by `name` having count(id) > 1as b where a.id=b.id and a.`name`=b.`name`


          posted on 2010-07-09 20:57 Ying-er 閱讀(2101) 評論(0)  編輯  收藏 所屬分類: MySql

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 苏州市| 若羌县| 乐亭县| 延吉市| 七台河市| 瑞金市| 永嘉县| 赤壁市| 莱州市| 桃源县| 沁水县| 承德县| 大足县| 紫云| 礼泉县| 三江| 昌江| 青神县| 郸城县| 湘乡市| 松溪县| 延吉市| 满洲里市| 葫芦岛市| 霍城县| 扶绥县| 饶河县| 上林县| 郴州市| 贡山| 霞浦县| 沾益县| 四会市| 鹤庆县| 柏乡县| 宿州市| 武城县| 瑞丽市| 石嘴山市| 高尔夫| 山东省|