删除多余数据,只保留id最小的数据

删除多余数据,只保留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

)
上一篇:confluence rce ssti CVE-2019-3396


下一篇:Confluence 6 从 WIKI 标记整合到基于 XHTML 的存储格式