i have a database with email and unique ID now i want to delete all duplicate emails from database ..
omoutop
6:40 am on Jun 28, 2006 (gmt 0)
One easy way (if you dont mind losing the id's) is:
- select email from table - construct array of ALL emails - use array_unique() - delete db - insert array elements into db
Scally_Ally
10:43 am on Jun 28, 2006 (gmt 0)
dont know what database you are using but an sql statement something like
delete from myTable where (field1, field2) not in ( select distinct(field1), field2 from myTable);
should do the trick
coopster
2:45 pm on Jun 28, 2006 (gmt 0)
Sounds like you have your table setup incorrectly if you truly don't want duplicate email columns in there. You may want to either add the email column to your PRIMARY KEY definition or use a UNIQUE index on the column.
coopster
6:25 pm on Jul 1, 2006 (gmt 0)
I also forgot to mention that before you do any type of updating such as this it is a very wise idea to make a backup copy of the file you will be mass updating.