I have a SELECT SQL that returns the following result:
Gender Number
Female: 15967
Male: 19739
The SQL is as follows:
SELECT gender, COUNT(gender) AS number FROM links GROUP BY gender ORDER BY gender
Now what I want hopefully should be pretty easy. I want to be able to associate the Gender results with a particular color. So for example, the result I need is:
Gender Number Color
Female: 15967 #62ACD7
Male: 19739 #38DA9F
This should be able to be accomplished without creating another field in the links table called Color. This should all fall within the SELECT query I think??? Also, I need for this to also work with queries that return more than 2 rows, i.e.
Country: Number Color
Albania: 24 #62ACD7
Algeria: 37 #38DA9F
Argentina: 15 #38DA3C
Australia: 272 #C9DA38
Thank you so much. If there is some php programming required to get this result, then that would work fine as well, but I am hoping this can all be accomplished with the SELECT query.
Robert
Quick SQL Question
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I think it's easier to do this all through php, rather than writing a very complicated query.
these may help if I understand you correctly.
viewtopic.php?t=26343
viewtopic.php?t=13897
these may help if I understand you correctly.
viewtopic.php?t=26343
viewtopic.php?t=13897