Forums

This topic is locked

Delete Duplicate Records in MySQL

Posted 24 Jun 2003 06:20:46
1
has voted
24 Jun 2003 06:20:46 Norman Buangan posted:
I have a registration database with name, email, address, etc.

The problem is that I have some entries with the same email address. What I want to do run an SQL statement which finds duplcates in the database, keep one, and remove the duplicates.

Does such a command exist in SQL?

I'm running:
- Win XP Pro IIS
- ASP
- MySQL 4

Thanks in advanced.

Replies

Replied 30 Jun 2003 11:16:48
30 Jun 2003 11:16:48 Julio Taylor replied:
what about something like
<pre id=code><font face=courier size=2 id=code>
DELETE FROM table WHERE COUNT(e-mail) &gt; 1 GROUP BY email
</font id=code></pre id=code>
not sure if it works. just an idea

------------------------
Julio

PHP | MySQL | DWMX

ICQ: 19735247
MSN:
Replied 03 Jul 2003 19:44:21
03 Jul 2003 19:44:21 Stephen Cox replied:
You could also use SELECT and copy the good records to a temp table, delete the old table and then rename the temp table.

Stephen Cox
web.net geek

Reply to this topic