From: Martin Ramsch Date: March 20 1999 6:43pm Subject: Re: Help with query, plz List-Archive: http://lists.mysql.com/mysql/693 Message-Id: <19990320194359.A28496@forwiss.uni-passau.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sa, 1999-03-20 11:25:51 -0700, Thimble Smith wrote: > COUNT(DISTINCT(...)) doesn't work in MySQL (yet). Try this: > > SELECT COUNT(*) FROM table GROUP BY ip; Not again! I really wonder why people keep on giving this wrong answer ...? Thimble, this query only gives how many of each distinct value you have, but not the number of distinct values. The right answer is that it's not possible to do SELECT COUNT(DISTINCT field) ... or equivalent with a single SQL query using MySQL up to 3.22.20a. But, if you're not restricted to the SQL level only, as in most cases where you use some host language to handle your queries, look at the function mysql_num_rows() in MySQL's API. If you can access this functionality with your host language, then just SELECT DISTINCT field FROM table; and then get the number of results. Regards, Martin -- Martin Ramsch PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26 E4 EC 80 58 7B 31 3A D7