Loop through array, change headings [message #184432] |
Tue, 31 December 2013 21:08 |
Adrienne Boswell
Messages: 25 Registered: October 2010
Karma:
|
Junior Member |
|
|
I'm sure this has been asked and answered, but I am either too stupid to
figure out the right way to ask Google, or I'm lazy, or it really hasn't
been asked. Sorry in advance, and if it has been answered, please refer
me as needed.
Here's my situation:
I have a table that has three classifications:
id Classification
1 Stores
2 Restaurants
3 Services
I have another table that has categories in each classification, eg.
id Category Classification_id
1 Market 1
2 Pet Shop 1
3 Pizza 2
4 Sandwich 2
5 Notary 3
6 Repair 3
My query is
SELECT c.id, category, classification, cl.id AS classid FROM category
c JOIN classification cl ON c.classification_id = cl.id ORDER BY classid,
category
What I want to do is:
-Stores
Market
Pet Shop
-Restaurants
Pizza
Sandwich
-Services
Notary
Repair
So, as I'm looping through my recordset, if the classid has changed, I
want to change the header. I don't want to make one query to get the
headings, and then do another query for each classid. I KNOW there has
got to be a better way.
I'm trying to get this all done so I can have a Happy New Year, and
wishing you and yours a Happy New Year as well.
--
Adrienne Boswell
Arbpen Web Site Design Services - http://www.cavalcade-of-coding.info/
The Good Plate - Fresh Gourmet Recipes - http://the-good-plate.com/
Please respond to the group so others can share
|
|
|