Try something like:

   SELECT
    C. CategoryName As ChildName,
    P. CategoryName as ParentName

   FROM
    Category C left outer join Category P
     ON C.ParentCategoryID = P. CategoryID

JThe join logic is the same as if it were in two tables... ypou are 
just aliasing, and joining to itself

HTH

Dick

At 12:03 AM -0700 7/23/01, [EMAIL PROTECTED] wrote:
>Seems like this should be easy, but I can't think how to construct
>a query that will grab the name of a parent category in the following
>situation...
>
>My category table consists of:
>CategoryID
>CategoryName
>ParentCategoryID
>
>If a category has a parent, ParentCategoryID carries the ID of the
>parent. If it doesn't, ParentCategory = 0.
>
>I'm trying to create a single query listing all the categories, and
>ALSO including a query column called ParentCategoryName,
>containing the name of the parent if that category has one. Could
>do it easily if the info were in 2 tables, but not sure how when all
>the info is in 1 table...
>
>Gene Kraybill
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to