qadenza
qadenza

Reputation: 9293

how to delete only unique values from a mysql table

I need to delete only unique values from a table. Something like:

delete from clients where title is unique

How to do this?

Upvotes: 0

Views: 59

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

You could try using a join with th count for title having count = 1

delete c
from clients  c
inner join (
    select title 
    from clients 
    group by title 
    having count(*) = 1

) t on t.title  = c.title

Upvotes: 3

Related Questions