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

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


          網站導航:
           
          主站蜘蛛池模板: 海宁市| 五家渠市| 固始县| 大埔县| 且末县| 云龙县| 汶川县| 色达县| 丰台区| 筠连县| 淮南市| 肇东市| 都匀市| 堆龙德庆县| 班玛县| 房产| 绥中县| 武宣县| 格尔木市| 永靖县| 比如县| 夹江县| 潜江市| 海口市| 丰镇市| 文水县| 安康市| 五莲县| 开原市| 称多县| 诸城市| 木兰县| 华坪县| 龙里县| 定州市| 汉川市| 北京市| 邯郸县| 宝山区| 卢氏县| 金秀|