List:General Discussion« Previous MessageNext Message »
From:Ben Clewett Date:February 14 2008 4:56pm
Subject:Re: select unique ?
View as plain text  
Try:

SELECT DISTINCT Colour FROM table;

Or, if you want to do it correctly:

SELECT Colour FROM table GROUP BY color;

Richard wrote:
> Hello,
> 
> I don't know if it is possible to do this with mysql alone ...
> Here goes :
> I've got a database list which is like to following :
> 
> Num    |    Name    |    Colour
> -------------------------------------------
> 1    |    Harry    |    Red
> 2    |    Tom    |    Blue
> 3    |    Jane    |    Green
> 4    |    Philip    |    Red
> 5    |    Sarah    |    Red
> 6    |    Robert    |    Blue
> 
> 
> And from this table I wish to get a list of used colours.
> 
> The correct answer would be :
> 
> Colour
> ---------
> Red
> Blue
> Green
> 
> The answer I don't want :
> 
> Colour
> --------
> Red
> Blue
> Green
> Red
> Red
> Blue
> 
> How would I achieve the first result with mysql ? Is it possible?
> 
> 
> Thanks in advance,
> 
> Richard
> 
Thread
select unique ?Richard14 Feb
  • Re: select unique ?peter lovatt14 Feb
  • Re: select unique ?Ben Clewett14 Feb
    • RE: select unique ?Randall Price15 Feb
      • Re: select unique ? (solved thankyou :))Richard16 Feb
      • Re: select unique ?Baron Schwartz16 Feb