Select * Where sortoflikeDistinct(`column`);

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Select * Where sortoflikeDistinct(`column`);

Post by Skara »

Er.. I have rows something like:

Code: Select all

324, file1.jpg, park
325, file1.jpg, green
326, file1.jpg, ugly

682, file5.jpg, ocean
683, file5.jpg, green

938, file8.jpg, ocean
Now, I need a query to give me all the different tags (the last row (park, green, etc)).
From the above rows, I would expect back: park, green, ugly, ocean.

Basically, I need a DISTINCT that works on a single column. Is there some way I can do that in the query?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

select only that column.
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Code: Select all

SELECT DISTINCT(yourcolumn) FROM yourtable;
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

huh. Well. huh. You know, I really don't know what the hell I was thinking. Really.
I guess I thought it would still be distinct per row...

Aaaanyway, thanks!
Post Reply