Gulmuhammad Akbari Gulmuhammad Akbari - 1 year ago 91
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.


Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download