Gulmuhammad Akbari Gulmuhammad Akbari - 2 months ago 4
MySQL Question

Mysql remove duplicate rows base on column value but keep the latest one

I have a table with 3 fields (phonecall,calldate,checked) and I want to remove duplicate rows by the phonecall column value but not the latest one.

enter image description here

In this scenario I want to delete 2 rows from the first of this table.



Like this:

delete A from TableX A
  left join TableX B
    on B.CallDate>A.CallDate and B.PhoneCall=A.PhoneCall
 where B.PhoneCall is not null