/    Sign up×
Community /Pin to ProfileBookmark

Restrict results to one per category

in my table i have details about each product and one of the fields is for category.

so each item has a category given to it, ie tees, hoodies, shirts etc etc

i used the following code to go through and list all categories in table:

[CODE]
SELECT tblproducts.category
FROM tblproducts
[/CODE]

i’m using this to build a menu for the site. but at the moment it lists it like this:

tees
tees
tees
hoodies
hoodies
shirt

and so on.

how can i restrict it to only show each category once?

do i need a seperate table with just categories in or can i limit each one?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Feb 12.2007 — Use:SELECT tblproducts.category
FROM tblproducts
GROUP BY tblproducts.category
ORDER BY tblproducts.category
Copy linkTweet thisAlerts:
@sean1983ukauthorFeb 12.2007 — many thanks
Copy linkTweet thisAlerts:
@NightShift58Feb 12.2007 — many welcome
×

Success!

Help @sean1983uk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...