Corkyballs
MIS
I have an SQL table which holds details of several company’s staffing hierarchies.
Each row in the table called Hierachy has a CodeID which is the auto-numbering key, a Level ID (1 being the top level), a description and a Parent Code ID.
The parent code ID refers back to a Level ID unless it has a top level position in which case the Parent Code ID is equal to 0.
There may be up to 5 levels below the top level position. eg a top level is a company, the second level could be regions, the third level branches, the fourth level departments and the fifth level staff.
There are more than 1 top level companies.
Given a Hierarchy ID how do I construct a query to return the top level position to which it ultimately refers.
Please help as my brain has melted 8-p
Each row in the table called Hierachy has a CodeID which is the auto-numbering key, a Level ID (1 being the top level), a description and a Parent Code ID.
The parent code ID refers back to a Level ID unless it has a top level position in which case the Parent Code ID is equal to 0.
There may be up to 5 levels below the top level position. eg a top level is a company, the second level could be regions, the third level branches, the fourth level departments and the fifth level staff.
There are more than 1 top level companies.
Given a Hierarchy ID how do I construct a query to return the top level position to which it ultimately refers.
Please help as my brain has melted 8-p