A question regarding SQL

lambada

New Member
Messages
2,444
Reaction score
0
Points
0
HI,
ON my site I have a links database with the Unique ID, Name, URL and Category.

Now, short of adding another table and 'mapping the categorys with numerical counterparts, is there any way to grab the categorys from that table but only if they are uniquie - this is for a dropdown category selector you see.

--------------------------
ID | Category |
1 | Friend |
2 | Humour |
3 | Humour |
4 | Friend |

etcetera
So if I do an SQL SELECT category FROM links ORDER BY Category. It would get all of the categorys even if they have been repeated, so using a loop code the searchbox would endup as Select: Friend, Friend, Humour, Humour, Humour. The categories would be listed multiple times.

Is there anyway around this short of getting a new table and linking via cat_id which I could do, but not really what I want.
 

theblazingangel

New Member
Prime Account
Messages
90
Reaction score
0
Points
0
SELECT DISTINCT category FROM links ORDER BY Category ASC
 
Last edited:

lambada

New Member
Messages
2,444
Reaction score
0
Points
0
Thanks that worked great :) - My php/mysql book didn't mention distinct atall!
 
Top