Ian Buzer wrote:
> 
> This has been bugging me for about 3 years now, and I've finally decided to 
> see if I can beat it (er... well see if I can find someone else that can beat 
> it :)
> 
> I've got a db table with a typical category heirachy structure:
> 
> categoryId, parentCategoryId, categoryName,  etc..
> 
> Given a particular categoryId, is it possible to get the path back to the 
> root category in only one db query?

In SQL this is possible using the WITH (RECURSIVE) construct. DB2 
implements this currently and the next version of MS SQL Server 
will implement this. In Oracle and custom PostgreSQL builds you 
can achieve the same using the CONNECT BY statement which has 
slightly different semantics.

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188616
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to