List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:May 1 1999 10:03am
Subject:Re: DISTINCT and COUNT() SQL Query
View as plain text  
This has been answered correctly and incorrectly many times.  If
you read the archives you'll find it.  If anyone is compiling a
list of FAQs, this is definitely one that should be on it.

The correct answer, for now, is this:

do this query:
    SELECT DISTINCT name FROM table_name;

or (is the same as):
    SELECT name FROM table_name GROUP BY name;

Now what you're looking for is in mysql_num_rows().  Look at the
C API description of mysql_num_rows for warnings about mysql_
use_result vs. mysql_store_result.

Tim

On Fri, Apr 30, 1999 at 09:44:05PM -0700, Mike Machado wrote:
> Yes! I want the number of distinct names. None of the earlier
> queries give me what I'm looking for. I want the number of
> distinct names in the same way as a 'select count(*) from
> names' would, exept that would give me all the entries (count
> the same name multiple times).
Thread
DISTINCT and COUNT() SQL QueryMike Machado1 May
  • Re: DISTINCT and COUNT() SQL Queryjkraai1 May
    • Re: DISTINCT and COUNT() SQL QueryPaul DuBois1 May
  • RE: DISTINCT and COUNT() SQL QueryDon Read1 May
  • Re: DISTINCT and COUNT() SQL QueryMike Machado1 May
    • Re: DISTINCT and COUNT() SQL QueryThimble Smith1 May
  • Re: DISTINCT and COUNT() SQL QueryJim Faucette1 May
  • 3.22.21 RAM Usagejkraai2 May
    • 3.22.21 RAM UsageMichael Widenius2 May
  • Re: 3.22.21 RAM Usagejkraai2 May
  • a problemglen19 May
    • Re: a problem (The table 'SQL134597_0' is full)Pete Harlan20 May
      • Re: a problem (The table 'SQL134597_0' is full)glen20 May
        • Re: a problem (The table 'SQL134597_0' is full)Benjamin Pflugmann21 May
        • Re: a problem (The table 'SQL134597_0' is full)Michael Widenius24 May