删除多余数据,只保留id最小的数据
DELETE
FROM
ship_plan_vessel_voyage_data
WHERE
(carrier_code,vessel_name, voyage) IN
(select carrier_code,vessel_name, voyage from
(
SELECT
carrier_code,
vessel_name,
voyage
FROM
ship_plan_vessel_voyage_data
GROUP BY
carrier_code,
vessel_name,
voyage
HAVING
count(*) > 1
) temp
)
AND id NOT IN (
select id from
(
SELECT
min(id) id
FROM
ship_plan_vessel_voyage_data
GROUP BY
carrier_code,
vessel_name,
voyage
HAVING
count(*) > 1
) temp
)