MYSQL_实用 SQL_删除重复数据
DELETE
FROM
pub_goods
WHERE
goodsno IN (
SELECT
*
FROM
(
SELECT
goodsno
FROM
pub_goods
GROUP BY
goodsno
HAVING
COUNT(goodsno) > 1
) t1
)
AND mgoodsid NOT IN (
SELECT
*
FROM
(
SELECT
MIN(mgoodsid)
FROM
pub_goods
GROUP BY
goodsno
HAVING
COUNT(goodsno) > 1
) t2
)