Wednesday 14 September 2011

MYSQL count unique data

Here I had to select unique (none duplicated) email addresses from a table. You would do this if say, you were mailing club members but there are multiple family members with the same email address but, you only want to send an email to them once. Hey, no one likes their Inbox filling up with the same email!

Code:   
SELECT COUNT(DISTINCT email)
FROM members
WHERE (email != "" OR email IS NOT NULL);
   



No comments: