1. 程式人生 > >mysql刪除多余pk10網站出租數據

mysql刪除多余pk10網站出租數據

del 代碼 min sele update use 意思 需求 update in

需求為刪除mysql數據庫中重復數據,保留第一條

初步代碼為:pk10網站出租(企 娥:217 1793 408)

DELETE
FROM
base_phone_lable
WHERE
phone IN (
SELECT
phone
FROM
base_phone_lable
GROUP BY
phone
HAVING
count(phone) > 1
)
AND id NOT IN (
SELECT
min(id)
FROM
base_phone_lable
GROUP BY
phone
HAVING
count(phone) > 1
)

運行報錯

[Err] 1093 - You can‘t specify target table ‘base_phone_lable‘ for update in FROM clause

意思為不能在查詢該字段的同時修改該字段

mysql刪除多余pk10網站出租數據