mysql去除重复保留最新一条记录代码

来源:本站原创 浏览:238次 时间:2018-12-14
做网站找雨过天晴工作室


mysql去除重复保留最新一条记录代码


delete from ol_news
where title in ( select title from (
        select title from ol_news group by title having count(ID) > 1
    ) as TAB1 )
and ID not in (
    select ID from (
        select min(ID) as ID  from ol_news group by title having count(ID) > 1
    ) as TAB2
)