sql - Remove duplicate rows in MySQL -



sql - Remove duplicate rows in MySQL -

i have table next fields:

id (unique) url (unique) title company site_id

now, need remove rows having same title, company , site_id. 1 way using next sql along script (php):

select title, site_id, location, id, count( * ) jobs grouping site_id, company, title, location having count( * ) >1

after running query, can remove duplicates using server side script. but, want know if can done using sql query.

a easy way add together unique index on 3 columns. when write alter statement, include ignore keyword. so:

alter ignore table jobs add together unique index idx_name (site_id, title, company);

this drop duplicate rows. added benefit, future inserts duplicates error out. always, may want take backup before running this...

sql mysql duplicate-removal

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -