需求为删除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
意思为不能在查询该字段的同时修改该字段
原文地址:http://blog.51cto.com/13874335/2145824
时间: 2024-10-09 01:44:01