DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   MySQL (http://www.daniweb.com/forums/forum126.html)
-   -   A mysql select question. (http://www.daniweb.com/forums/thread71541.html)

nickclarson Mar 4th, 2007 12:49 am
A mysql select question.
 
I have a db full of articles that have a category field.

Is there anyway to select and display just the different categories?

ses5909 Mar 4th, 2007 9:41 am
Re: A mysql select question.
 
Sure...

select distinct category from articles;

nickclarson Mar 4th, 2007 1:52 pm
Re: A mysql select question.
 
No, that's easy. What I am trying to do is make a list of the categories in the database without already knowing what is in it so oI can make a menu with links.

GliderPilot Mar 5th, 2007 6:34 pm
Re: A mysql select question.
 
asuming your field is named catagory your SELECT command would look something like this:

SELECT DISTINCT catagory FROM article_db ORDER BY catagory;

This would go through the catagory field, select all the Unique entries so each catagory name only appears once, and displays them in alphabitical order.

nickclarson Mar 5th, 2007 6:40 pm
Re: A mysql select question.
 
Yea I noticed that other user up there was right too. Thanks! I figured it out!!


All times are GMT -4. The time now is 9:09 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC