php - SQL Delete Duplicate rows find same text in a field -
i using phpmyadmin - joomla cms. have many articles same title. want delete articles having same title. please tell me query how delete same articles having same title.
i used command shows me count of articles having same title.
select title, id, count(title) q3ept_k2_items group title having count(title) > 1
please try this,
for keep lowest id value,
delete item1 q3ept_k2_items item1, q3ept_k2_items item2 item1.id > item2.id , item1.title = item2.title
for keep highest id value,
delete item1 q3ept_k2_items item1, q3ept_k2_items item2 item1.id < item2.id , item1.title = item2.title
if want improve little bit performance, can change style,
where item1.title = item2.title , item1.id > item2.id
or
where item1.title = item2.title , item1.id < item2.id
Comments
Post a Comment