I have a table item that contains items like
name
------
alpha
alpha
beta
charlie
charlie
In this case how would I delete duplicate rows but one record should remain. The above table does not have any primary key.
Try this
DELETE FROM item WHERE GREATEST(0,@num := IF(NAME = @NAME, @num + 1, 0),LEAST(0, LENGTH(@NAME := NAME)))>0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With