I've got an odd issue. I've got the code working already, but I don't like
the way I had to go about it...

I have a table, that has an ID field, and a parent ID field that refers back
to the main ID. It's basically a parent/child deal - one 'master' ID record,
then each other one has another one as the parent, however many steps down
as necessary.

I'd like to code a single SQL query to dig through this table and only
return the IDs that are equal to or below, relationship-wise, a supplied
ID... so say the records are basically:

1 - Master Group
2 - Subgroup 1 (parent is 1)
3 - Subgroup 2 (parent is 1)
4 - Subgroup 1.1 (parent is 2)
5 - Subgroup 1.2 (parent is 2)
6 - Subgroup 2.1 (parent is 3)
7 - Subgroup 2.1.1 (parent is 6)

and I supplied ID "1", the query would return all records... but if I
supplied ID "3", it would only return 3,6,7.

Right now I'm running a loop with a condition, that taps the DB for each
tier, keeps track of the IDs it's returned, etc. until the condition is met
(an empty recordset, i.e. no more children). Not elegant :)

Thoughts?

Thanks in advance -
--Scott


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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