I have a self referencing table:
tableID, tableinfo, parentID
The top level items are when the parentID is equal to zero. Given a
tableID is there a way (in SQL) to find the number of all it's children (no
matter how deep)?
Getting it's children is easy:
select * from tableinfo
where parentID = #mytableID#
Then you can just use recordcount. But, that won't give you any of your
children's children. I know that I can just throw the above code in a loop
until their are no more children, but I was wondering if there was a better
way (a stored procedure, maybe?).
Any thoughts would be welcome. Thanks!
Jeffry Houser | mailto:[EMAIL PROTECTED]
AIM: Reboog711 | ICQ: 5246969 | Phone: 860-229-2781
--
Instant ColdFusion 5.0 | ISBN: 0-07-213238-8
Due out June 2001
--
DotComIt, LLC
database driven web data using ColdFusion, Lotus Notes/Domino
--
Half of the Alternative Folk Duo called Far Cry Fly
http://www.farcryfly.com | http://www.mp3.com/FarCryFly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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