本文介紹了如何刪除 MySQL 表上的重復(fù)項?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我需要在 MySQL
表上DELETE
指定 sid 的重復(fù)行.
I need to DELETE
duplicated rows for specified sid on a MySQL
table.
如何使用 SQL 查詢執(zhí)行此操作?
How can I do this with an SQL query?
DELETE (DUPLICATED TITLES) FROM table WHERE SID = "1"
類似這樣的事情,但我不知道該怎么做.
Something like this, but I don't know how to do it.
推薦答案
這會在原地刪除重復(fù)項,而無需創(chuàng)建新表
this removes duplicates in place, without making a new table
ALTER IGNORE TABLE `table_name` ADD UNIQUE (title, SID)
注意:只有當(dāng)索引適合內(nèi)存時才有效
note: only works well if index fits in memory
這篇關(guān)于如何刪除 MySQL 表上的重復(fù)項?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!