« Home | Mysql do bulk operations on tables, columns, infor... » | Joomla templating tutorials. » | Google Trends / Result count, of programming langu... » | Excellent video on performance testing with open s... » | Rediscover Web! » | Tools for IE HTTP header debugging » | Developing JavaScript with Chickenfoot » | Cool I am successfull !! in XSS attack!! » | XSS » | Understanding file permissions on Linux » 

Thursday, September 02, 2010 

Query to delete rows with duplicate columns.

Say you have table1 with field_name which is having duplicate records, and if you want to delete rows with duplicate columns, you can use the below query.

Assumes that you have a unique id, ID and the duplicate row is field_name.

delete from table1
USING table1, table1 as vtable
WHERE (table1.ID > vtable.ID)
AND (table1.field_name=vtable.field_name)