View Full Version : Echo distinct MySQL columns values?
Len Whistler
01-31-2007, 06:40 PM
Any way to echo distinct MySQL column values? I can only see COUNT(DISTINCT column). Example:
Red
Blue
Green
Blue
Blue
Would echo as:
Red
Blue
Green
guelphdad
01-31-2007, 08:07 PM
remove the count.
select distinct columnname from yourtablename
note that will only work for single columns, DISTINCT is not a function and works across all columns in a row.
for instance if you had
color1 and color2 as your columns and had the following values:
Orange Red
Orange Blue
Orange Green
Red Orange
Green Blue
all of those rows are distinct from one another so
select distinct color1, color2 from yourtablename
would return all of those rows.
Len Whistler
02-01-2007, 01:57 AM
Thanks guelphdad........The code is working.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.