SQL to return all descendants

Erick

Active Member
Joined
Feb 26, 2003
Messages
362
I have a table with 2 fields 'Elements' & 'Parent'. These 2 fields represent a hierarchial child-parent relationship (like treeview).
eg.

Element ----Parent
1
1.1 -----------1
1.2------------2
1.1.1----------1.1
1.1.1.1--------1.1.1
The depth of the hierarchy is variable. I need a query that will identify all the descendants of any particular element, so for element 1.1 all the descendants are 1.1.1 & 1.1.1.1.

I can probably get this result using some kind of look up loop in vba but I am hoping that an SQL query can return the same thing.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top