刪除數據庫中的重復記錄
          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 閱讀(2094) 評論(0)  編輯  收藏 所屬分類: MySql

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


          網站導航:
           
          主站蜘蛛池模板: 泸溪县| 抚宁县| 博湖县| 兴宁市| 宜兰市| 深水埗区| 青田县| 乐清市| 泉州市| 黄梅县| 民权县| 洪湖市| 政和县| 三穗县| 开江县| 伊金霍洛旗| 乌恰县| 栾川县| 二连浩特市| 岗巴县| 泰宁县| 普安县| 江阴市| 泸州市| 民勤县| 盖州市| 建阳市| 漳州市| 博白县| 盈江县| 海门市| 福安市| 樟树市| 会昌县| 湖北省| 沙洋县| 濉溪县| 融水| 理塘县| 天柱县| 威海市|