Remove duplicate rows in MySQL

前端 未结 25 4273
囚心锁ツ
囚心锁ツ 2020-11-21 04:33

I have a table with the following fields:

id (Unique)
url (Unique)
title
company
site_id

Now, I need to remove rows having same titl

25条回答
  •  半阙折子戏
    2020-11-21 05:31

    I like to be a bit more specific as to which records I delete so here is my solution:

    delete
    from jobs c1
    where not c1.location = 'Paris'
    and  c1.site_id > 64218
    and exists 
    (  
    select * from jobs c2 
    where c2.site_id = c1.site_id
    and   c2.company = c1.company
    and   c2.location = c1.location
    and   c2.title = c1.title
    and   c2.site_id > 63412
    and   c2.site_id < 64219
    )
    

提交回复
热议问题