Paul,

That worked  :-)
Thanks!

I am just gonna keep trying some things out to make sure this is the most
efficient way to do it.

Mike


-----Original Message-----
From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]] 
Sent: Friday, March 15, 2002 12:52 AM
To: CF-Talk
Subject: Re: SQL & CF Question


Try this out for size:

<cfquery datasource="datasource" name="getMainCats">
 select CategoryID, LnkCategoryID, CategoryTitle
 from tablename
 where LnkCategoryID = 0
</cfquery>

<cfoutput query="getMainCats">
 #getMainCats.CategoryTitle#
 <br>
 <cfquery datasource="datasource" name="getSubCats">
  select CategoryID, LnkCategoryID, CategoryTitle
  from tablename
  where LnkCategoryID = #getMainCats.CategoryID#
 </cfquery>
 <cfloop query="getSubCats">
 - #getSubCats.CategoryTitle#<br>
 </cfloop>
</cfoutput>

Paul Giesenhagen
QuillDesign
http://www.quilldesign.com
SiteDirector v2.0 - Commerce Builder


----- Original Message -----
From: "Tangorre, Michael T." <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, March 14, 2002 11:34 PM
Subject: SQL & CF Question


> Hi Everyone.
>
> Can someone help me out with the following problem.
> I have a table in my SQL DB called categories.
> In it there are 3 fields: CategoryID, LnkCategoryID, CategoryTitle 
> What I am trying to do is the following:
>
> When LnkCategoryID = 0 that means that that record is a Main Category. 
> So in my table there are 3 main categories right now:
>
> CategoryID = 1
> LnkCategoryID = 0
> CategoryTitle = Hardware
>
> CategoryID = 2
> LnkCategoryID = 0
> CategoryTitle = Software
>
> CategoryID = 3
> LnkCategoryID = 0
> CategoryTitle = Software
>
> Each Main Category can have subcategories and you can probably see 
> that
the
> LnkCategoryID becomes the CategoryID from the main categories.
>
> CategoryID = 4
> LnkCategoryID = 1
> CategoryTitle = Hard Drives
>
> CategoryID = 5
> LnkCategoryID = 1
> CategoryTitle = CD Rom Drives
>
> CategoryID = 6
> LnkCategoryID = 1
> CategoryTitle = Floppy Drives
>
> etc...etc..
>
> Well I am trying to output the Main Category with the lnked categories
below
> them such as:
>
> Hardware
> -Hard Drives
> -CD Rom Drives
> -Floppy Drives
>
> Software
> -Web Editors
> -Graphics
> -Operating Systems
>
> etc..
>
> How can I write the SQL Statement for this and use it with cfloop or
cfquery
> to get my desired results.
>
> My apologies for the long post, I tried for awhile to get it on my 
> own, I thought I would ask now.
>
> Thanks to anyone who can help. I am a novie SQL user/writer.
>
>
> Michael T. Tangorre
>
> ======================
> Alfred University
> Webteam Manager
> AIM: CrazyFlash4
> Phone: 607-426-9277
> ======================
> 

______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to