mysql - Delete duplicate rows with same text -


i have table news fields:

idnews idarea title text date

what want delete duplicate rows same title , text except 1 (the 1 earliest date) try query without success.

i tried these queries, didn't work:

delete news idnews not in (select min(date) news group title,text, date);   delete idnews news date< date , title= title , text=text; 

assuming idnews key should work:

delete news  idnews not in (   select idnews (     select idnews news     join (       select title, text, min(date) min_date        news       group title, text     ) x       on news.title = x.title     , news.text  = x.text      , news.date  = x.min_date   ) ); 

the reason nested joins mysql won't let delete data table you're directly referencing in join. second level subquery creates temporary result set allow delete.

sample sql fiddle


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -