Hi,
I'm trying to produce a nested list based on a 3-level relation.
Table:
Code:
+-------+---------------+---------------+-------+
|Level1 |Level2 |Level3 |Name |
+-------+---------------+---------------+-------+
|US |Vermont |Burlington |City |
+-------+---------------+---------------+-------+
|US |Vermont |Winchester |City |
+-------+---------------+---------------+-------+
|US |Vermont | |State |
+-------+---------------+---------------+-------+
|US |New York |Brooklyn |City |
+-------+---------------+---------------+-------+
|US |New York |Manhattan |City |
+-------+---------------+---------------+-------+
|US |New York | |State |
+-------+---------------+---------------+-------+
|CA |Alberta |Lake Town |City |
+-------+---------------+---------------+-------+
|CA |Alberta | |State |
+-------+---------------+---------------+-------+
Output: (Which I want to achieve)
Code:
- US
- Vermont
- Burlington
- Winchester
- New York
- Brooklyn
- Manhattan
- CA
- Alberta
- Lake Town
Query:
Code:
<cfquery name="Levels" datasource="#Source#">
SELECT *
FROM RELATION
WHERE Level3 = Level2
ORDER BY Level1
</cfquery>
Code:
[/code]
<cfoutput query="Levels" group="Level1">
- #Level1#
-#Level2#
-#Level3#
</cfquery>
[/code]
Thank you in advance
PS. I hope you can see the table properly