1) Find the duplicate records and classify them into a new table. max(id) is the record you want to delete
create table ttt as select gallery_url ,max(id) as< /span> theid from gallery group by gallery_url having count(*) >=2
2) Delete
delete from gallery where id in (sel ect theid from ttt)
create table ttt as select gallery_url ,max(id) as theid from gallery group by gallery_url having count(*) >=2< /pre>delete from gallery where id in (select theid from ttt)