久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='eR3lz'><tr id='eR3lz'><dt id='eR3lz'><q id='eR3lz'><span id='eR3lz'><b id='eR3lz'><form id='eR3lz'><ins id='eR3lz'></ins><ul id='eR3lz'></ul><sub id='eR3lz'></sub></form><legend id='eR3lz'></legend><bdo id='eR3lz'><pre id='eR3lz'><center id='eR3lz'></center></pre></bdo></b><th id='eR3lz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eR3lz'><tfoot id='eR3lz'></tfoot><dl id='eR3lz'><fieldset id='eR3lz'></fieldset></dl></div>
    <bdo id='eR3lz'></bdo><ul id='eR3lz'></ul>

<legend id='eR3lz'><style id='eR3lz'><dir id='eR3lz'><q id='eR3lz'></q></dir></style></legend>

    1. <tfoot id='eR3lz'></tfoot>
    2. <small id='eR3lz'></small><noframes id='eR3lz'>

      刪除除 MySQL 中的一行之外的所有重復行?

      Delete all Duplicate Rows except for One in MySQL?(刪除除 MySQL 中的一行之外的所有重復行?)
      <legend id='3reA0'><style id='3reA0'><dir id='3reA0'><q id='3reA0'></q></dir></style></legend>
    3. <small id='3reA0'></small><noframes id='3reA0'>

      1. <tfoot id='3reA0'></tfoot>
        <i id='3reA0'><tr id='3reA0'><dt id='3reA0'><q id='3reA0'><span id='3reA0'><b id='3reA0'><form id='3reA0'><ins id='3reA0'></ins><ul id='3reA0'></ul><sub id='3reA0'></sub></form><legend id='3reA0'></legend><bdo id='3reA0'><pre id='3reA0'><center id='3reA0'></center></pre></bdo></b><th id='3reA0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3reA0'><tfoot id='3reA0'></tfoot><dl id='3reA0'><fieldset id='3reA0'></fieldset></dl></div>

          • <bdo id='3reA0'></bdo><ul id='3reA0'></ul>

                <tbody id='3reA0'></tbody>
                本文介紹了刪除除 MySQL 中的一行之外的所有重復行?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                如何從 MySQL 表中刪除所有重復數據?

                How would I delete all duplicate data from a MySQL Table?

                例如,使用以下數據:

                SELECT * FROM names;
                
                +----+--------+
                | id | name   |
                +----+--------+
                | 1  | google |
                | 2  | yahoo  |
                | 3  | msn    |
                | 4  | google |
                | 5  | google |
                | 6  | yahoo  |
                +----+--------+
                

                如果是 SELECT 查詢,我會使用 SELECT DISTINCT name FROM names;.

                I would use SELECT DISTINCT name FROM names; if it were a SELECT query.

                我將如何使用 DELETE 執行此操作以僅刪除重復項并僅保留每個記錄?

                How would I do this with DELETE to only remove duplicates and keep just one record of each?

                推薦答案

                編輯器警告:此解決方案計算效率低下,可能會導致大表的連接中斷.

                注意 - 您需要首先在您的表的測試副本上執行此操作!

                NB - You need to do this first on a test copy of your table!

                當我這樣做時,我發現除非我還包含了 AND n1.id <>n2.id,它刪除了表中的每一行.

                When I did it, I found that unless I also included AND n1.id <> n2.id, it deleted every row in the table.

                1. 如果要保留 id 值最低的行:

                DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name
                

              • 如果要保留 id 值最高的行:

                DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name
                

              • 我在 MySQL 5.1 中使用過這種方法

                I used this method in MySQL 5.1

                不確定其他版本.

                更新:由于人們在谷歌上搜索刪除重復項最終會出現在這里
                盡管 OP 的問題是關于 DELETE,但請注意使用 INSERTDISTINCT 會快得多.對于一個有 800 萬行的數據庫,下面的查詢用了 13 分鐘,而使用 DELETE 時,用了 2 個多小時還沒有完成.

                Update: Since people Googling for removing duplicates end up here
                Although the OP's question is about DELETE, please be advised that using INSERT and DISTINCT is much faster. For a database with 8 million rows, the below query took 13 minutes, while using DELETE, it took more than 2 hours and yet didn't complete.

                INSERT INTO tempTableName(cellId,attributeId,entityRowId,value)
                    SELECT DISTINCT cellId,attributeId,entityRowId,value
                    FROM tableName;
                

                這篇關于刪除除 MySQL 中的一行之外的所有重復行?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                <i id='imUaS'><tr id='imUaS'><dt id='imUaS'><q id='imUaS'><span id='imUaS'><b id='imUaS'><form id='imUaS'><ins id='imUaS'></ins><ul id='imUaS'></ul><sub id='imUaS'></sub></form><legend id='imUaS'></legend><bdo id='imUaS'><pre id='imUaS'><center id='imUaS'></center></pre></bdo></b><th id='imUaS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='imUaS'><tfoot id='imUaS'></tfoot><dl id='imUaS'><fieldset id='imUaS'></fieldset></dl></div>

                    <tbody id='imUaS'></tbody>

                        <bdo id='imUaS'></bdo><ul id='imUaS'></ul>
                          <legend id='imUaS'><style id='imUaS'><dir id='imUaS'><q id='imUaS'></q></dir></style></legend>

                          <small id='imUaS'></small><noframes id='imUaS'>

                          <tfoot id='imUaS'></tfoot>
                        • 主站蜘蛛池模板: 羞视频在线观看 | 国产欧美一区二区三区久久 | 久久成人18免费网站 | 羞羞视频免费观看 | 亚洲欧美精品久久 | 不卡在线视频 | 欧美黄页| 一区二区三区韩国 | 国家aaa的一级看片 h片在线看 | 成人久久视频 | 亚洲精品自在在线观看 | a级黄色片视频 | 男人阁久久 | 欧美成人性生活 | 亚洲免费在线观看视频 | 一区二区在线不卡 | 97精品一区二区 | 日韩精品在线播放 | 黄色国产 | 成人国产一区二区三区精品麻豆 | 免费在线观看成人 | 日韩在线中文字幕 | 日日操操 | 国产一区二区三区四区 | 青青艹在线视频 | 亚洲有码转帖 | 天天草视频| 久久久免费精品 | 日韩一区二区三区四区五区六区 | 国产欧美日韩精品一区二区三区 | 一区二区在线不卡 | 国产91在线播放 | 亚洲综合小视频 | 免费特级黄毛片 | 亚洲免费一区二区 | 欧美a在线看 | 日韩欧美国产一区二区 | 亚洲午夜电影 | 欧美淫片 | 午夜精品久久久久久不卡欧美一级 | 国产成人高清 |