In mysql, how to solve this sql?

DELETE FROM tusers WHERE (code,name) in(SELECT code,name FROM tusers GROUP BY code,name HAVING COUNT(*) > 1)

Why can"t I write like this? How do you write this?

Mar.18,2021

  • Why can't you write like this

     --
     
    Delete from [tusers] where id not in
    (
            SELECT MAX(id)        --max(id) :min(id)
    
            FROM [tusers]
    
            GROUP BY code,name    --group by
    )
Menu