dvanderb
dvanderb

Reputation: 757

Count unique records in database

This is probably an easy question, but I can't seem to find the answer on here. I have written a query that yields a list of email addresses. The list has duplicate records, so I did a "GROUP BY email" so that I could print out a list of only unique values. I also need the count of unique emails so that my loop works properly. How do I get that number? mysql_num_rows is giving the total including duplicate emails.

Upvotes: 0

Views: 661

Answers (1)

Fokko Driesprong
Fokko Driesprong

Reputation: 2250

Try:

SELECT COUNT( DISTINCT( email ) ) FROM table

Upvotes: 3

Related Questions