Monday, September 29, 2008

MySQL Count Distinct

I was having trouble trying to count up the number of enries in a database.  I was doing a join and wanted only the unique entries from another table so that I wouldn't get a inflated count.

You can do a COUNT with the DISTINCT tag in it to accomplish this.

Example:
SELECT COUNT(DISTINCT results) FROM student;

No comments: