Hi Kelly,

>
> So basically SI_Items has the category ID for each item to show what
> category it belongs to. All Good...
> I want the output however to look like so.
>
[snip]
> I seem to be having trouble. Obviously something has to loop and
> maybe even
> group (ooo a rhyme)
> because once I pull all items I have the Category ID for each but
> need to go
> back to the category table
> to find out what that category actually is. Also need the categories
> displayed BY NAME (from category table)
> with the items for each category (item table) listed under the appropriate
> Category. i am srue I am
> missing something little. Any suggestions???
>
> Should I do 2 separate queries or a join? I have tried quite a few things
> and can't get it to work.


Looks like what you need to do is :

SELECT SI_Categories.SI_Category_ID, SI_Categories.SI_Category_Name,
SI_Items.SI_Item_ID,
 SI_Items.SI_Item_Name
FROM SI_Categories, SI_Items
WHERE SI_Categories.SI_CategoryID = SI_Items.SI_Category_ID
ORDER BY SI_Category_Name

Then you need to do a nested CFOUTPUT using the GROUP attribute

<cfoutput QUERY="YourQuery" group="SI_Category_Name">
        <p>#SI_Catgeory_Name#<BR>
        <cfoutput>
        #SI_Item_Name#
        </cfoutput>
</cfoutput>

This way you have one hit on the database, the database deals with the
ordering of the data and you get your sets of categories with their items.

HTH

Regards

Stephen



------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to