View Single Post
  #2 (permalink)  
Old 01-14-04, 12:30 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

I'm not sure if you've figured out yourself, but for future reference...

ASSUMING that your `emails` table has only one field `email` (besides your PK that you are willing to let go), you can apply DISTINCT keyword and put the results into a new table.

Code:
SELECT DISTINCT email FROM emails;
Run this SQL statement, and you will get unique email addresses. Say, if you have:

Code:
+----+----------------+
| id | email          |
+----+----------------+
|  1 | amy@foo.com    |
|  2 | bob@bar.net    |
|  3 | amy@foo.com    |
|  4 | cathy@hoge.org |
|  5 | bob@bar.net    |
+----+----------------+
Then the above SQL statement with DISTINCT keyword will give you this:

Code:
+----------------+
| email          |
+----------------+
| amy@foo.com    |
| bob@bar.net    |
| cathy@hoge.org |
+----------------+
Then, you can use a loop or something to insert these emails into a new table or generate a CSV file and import it from MySQL.

HTH.
__________________
Blavv =|
Reply With Quote