Hopefully, there is someone who knows how to solve this, I've been working on it for a few hours and I've got myself absolutely nowhere...
I have a database (built in MSAcess), it has a series of records (which if I understand databases correctly, that's normal).
Each record can be assigned a ParentID, which is the ID of another record.
My table looks like this:
I would like to take the contents of that table and arrange it into a hierarchy structure. The output would look like this:
As well as listing one record's lineage like this:
Ideally, I'd like to take that minimal amount of information necessary (all the information shown in the table above), and have it display the hierarchy, however SQL has decided it doesnt want to cooperate with Yahweh.
It seems all the little tutorials I've read do not give me solutions which are easily implemented.
Me and SQL do not get along very well, it seems everything more sophisticated than SELECT, UPDATE, INSERT, DELETE only hurts SQL's feelings, making it give me completely vauge "Syntax Error on Line 72" complaints.
It seems that something like this can be solved with a recursive function, that is much easier said than done with the example table I've given.
Preferably, I'd like to see how this can be solved using ASP, although I could probably figure out what I'm doing just as soon as I know the table is ordered correctly.
If anyone can help me out, I would appreciate it.
I have a database (built in MSAcess), it has a series of records (which if I understand databases correctly, that's normal).
Each record can be assigned a ParentID, which is the ID of another record.
My table looks like this:
Code:
Table1
<table width="70%" cellpadding="1" cellspacing="0" border="1" style="font-size:9pt;font-family:Courier New;">
<tr>
<td bgcolor="#c0c0c0" width="10%">[b]ID[/b]
(Autonumber)</td>
<td bgcolor="#c0c0c0" width="70%">[b]Name[/b]
(Text)</td>
<td bgcolor="#c0c0c0" width="20%">[b]ParentID[/b]
(Number)</td>
</tr>
<tr>
<td>1</td>
<td>Main Directory</td>
<td>NULL</td>
</tr>
<tr>
<td>2</td>
<td>Yahweh</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>ASP Files</td>
<td>2</td>
</tr>
<tr>
<td>5</td>
<td>shanek</td>
<td>1</td>
</tr>
<tr>
<td>6</td>
<td>Eos of the Eons</td>
<td>1</td>
</tr>
<tr>
<td>7</td>
<td>Cool Libertarian Stuff</td>
<td>5</td>
</tr>
<tr>
<td>8</td>
<td>Even Cooler Libetarian Stuff</td>
<td>7</td>
</tr>
<tr>
<td>4</td>
<td>Pretty Ponies</td>
<td>2</td>
</tr>
<tr>
<td>9</td>
<td>Anti-Homeopathy Illuminati</td>
<td>6</td>
</tr>
<tr>
<td>10</td>
<td>Totally Macho Libertarian Stuff</td>
<td>8</td>
</tr>
</table>
I would like to take the contents of that table and arrange it into a hierarchy structure. The output would look like this:
Code:
Main Directory
....Yahweh
........ASP Files
........Pretty Ponies
....shanek
........Cool Libertarian Stuff
............Even Cooler Libertarian Stuff
................Totally Macho Libertarian Stuff
....Eos of the Eons
........Anti-Homeopathy Illuminati
As well as listing one record's lineage like this:
Code:
(Listing lineage of record #8)
Main Directory > shanek > Cool Libertarian Stuff > Even Cooler Libertarian Stuff
Ideally, I'd like to take that minimal amount of information necessary (all the information shown in the table above), and have it display the hierarchy, however SQL has decided it doesnt want to cooperate with Yahweh.
It seems all the little tutorials I've read do not give me solutions which are easily implemented.
Me and SQL do not get along very well, it seems everything more sophisticated than SELECT, UPDATE, INSERT, DELETE only hurts SQL's feelings, making it give me completely vauge "Syntax Error on Line 72" complaints.
It seems that something like this can be solved with a recursive function, that is much easier said than done with the example table I've given.
Preferably, I'd like to see how this can be solved using ASP, although I could probably figure out what I'm doing just as soon as I know the table is ordered correctly.
If anyone can help me out, I would appreciate it.