Home > Archive > SQL Anywhere database > June 2005 > Re: Recursive Queries - Figured It Out









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Recursive Queries - Figured It Out
Dennis Perkins

2005-06-13, 9:23 am

This seems to always happen. After I post, I solve the
problem myself. Although it may not be the best solutions
it does work. The query is below.


CategoryTree ( sys_Category, Sys_CategoryP,Id,
Description, TreeLevel,TreeSort) AS
( ( Select Sys_Category, Sys_CategoryP, Id,
Description, 1,id
From Category as c
Where Sys_CategoryP is Null)
Union All
(Select c.Sys_Category, c.Sys_CategoryP, c.Id,
c.Description, p.TreeLevel + 1,p.treesort+c.id
From Category c Join CategoryTree p
On c.Sys_CategoryP = p.Sys_Category ) )
Select * From CategoryTree
Order by treesort
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com