List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:September 24 1999 10:50pm
Subject:Re: Counting "Distinct"
View as plain text  
At 15:39, 19990924, Thomas Miller Hall wrote:
>Is there a way to count the number of "distinct" elements of a certain
>column of a table?

Does count(distinct) work yet in 3.23?  I don't have access to it to
tell.

If it doesn't, or if you're not using 3.23 yet, then you can do this
trick:

    SELECT foo FROM table GROUP BY foo;

After executing that query, check the number of rows returned (mysql_
num_rows in the C API, $dbh->rows in Perl).  That's the number you
want.

Tim
Thread
Counting "Distinct"Thomas Miller Hall25 Sep
  • Re: Counting "Distinct"Thimble Smith25 Sep
    • Re: Counting "Distinct"Jani Tolonen26 Sep
  • Re: Counting "Distinct"Paul DuBois25 Sep