Given a table with some non-unique column theCol, what is the most efficient
way to count the number of different values in theCol? I guess you can use a
temporary table as a subselect:

CREATE TEMPORARY TABLE tmp SELECT UNIQUE theCol FROM theTable;
SELECT COUNT(*) FROM tmp;
DROP TABLE tmp;

But this seem obscenely inefficient- it's a situation just screaming out for
a summary function:

SELECT COUNT_UNIQUE(theCol) FROM theTable;

Does such a function exist in mySQL? Is one planned?

Further, using the first method, what are the efficiency and robustness
differences between using 'SELECT UNIQUE theCol' and 'SELECT theCol GROUP BY
theCol'?


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to