Skip to content

Commit ae138ea

Browse files
committed
Update MP SELECT Ancestors.md
1 parent 9c36062 commit ae138ea

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

MP SELECT Ancestors.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ WITH
7171
),
7272
ancestors AS (
7373
SELECT ascii_id,
74-
replace(replace(substr(fullkey, 3), '.', '/'), '^#^', '.') || '/' AS asc_path
74+
replace(replace(substr(fullkey, 3), '.', '/'), '^#^', '.') || '/' AS asc_path,
75+
replace("key", '^#^', '.') AS asc_name
7576
FROM
7677
json_prefixes AS jp,
7778
json_tree(replace(jp.prefix_json, '.', '^#^')) AS prefixes
@@ -84,14 +85,14 @@ Blocks *json_nodes* through *tops* constitute the same prologue as [before](sele
8485

8586
**Output**
8687

87-
| ascii_id | asc_path |
88-
|----------|---------------------------|
89-
| 0FDAF2C8 | tcl/ |
90-
| 0FDAF2C8 | tcl/compat/ |
91-
| BE0A8514 | tcl/ |
92-
| BE0A8514 | tcl/pkgs/ |
93-
| BE0A8514 | tcl/pkgs/thread2.8.7/ |
94-
| BE0A8514 | tcl/pkgs/thread2.8.7/tcl/ |
88+
| ascii_id | asc_name | asc_path |
89+
|----------|-------------|---------------------------|
90+
| 0FDAF2C8 | tcl | tcl/ |
91+
| 0FDAF2C8 | compat | tcl/compat/ |
92+
| BE0A8514 | tcl | tcl/ |
93+
| BE0A8514 | pkgs | tcl/pkgs/ |
94+
| BE0A8514 | thread2.8.7 | tcl/pkgs/thread2.8.7/ |
95+
| BE0A8514 | tcl | tcl/pkgs/thread2.8.7/tcl/ |
9596

9697
---
9798

@@ -118,14 +119,13 @@ WITH
118119
FROM levels
119120
),
120121
ancestors AS (
121-
SELECT min(jo.id) AS id,
122-
replace(replace(substr(fullkey, 3), '.', '/'), '^#^', '.') || '/' AS asc_path
122+
SELECT jo.id,
123+
replace(replace(substr(fullkey, 3), '.', '/'), '^#^', '.') || '/' AS asc_path,
124+
replace("key", '^#^', '.') AS asc_name
123125
FROM
124126
json_objs AS jo,
125127
json_tree(replace(jo.json_obj, '.', '^#^')) AS terms
126128
WHERE terms.parent IS NOT NULL
127-
GROUP BY asc_path
128-
ORDER BY id, asc_path
129129
)
130130
SELECT * FROM ancestors;
131131
~~~
@@ -134,13 +134,13 @@ This query splits paths as provided and no longer accesses the *categories* tabl
134134

135135
**Output**
136136

137-
| id | asc_path |
138-
|----|----------------------------------|
139-
| 1 | tcl/ |
140-
| 1 | tcl/compat/ |
141-
| 1 | tcl/compat/zlib1/ |
142-
| 2 | tcl/pkgs/ |
143-
| 2 | tcl/pkgs/thread2.8.7/ |
144-
| 2 | tcl/pkgs/thread2.8.7/tcl/ |
145-
| 2 | tcl/pkgs/thread2.8.7/tcl/cmdsrv/ |
146-
137+
| id | asc_name | asc_path |
138+
|----|-------------|----------------------------------|
139+
| 1 | tcl | tcl/ |
140+
| 1 | compat | tcl/compat/ |
141+
| 1 | zlib1 | tcl/compat/zlib1/ |
142+
| 2 | tcl | tcl/ |
143+
| 2 | pkgs | tcl/pkgs/ |
144+
| 2 | thread2.8.7 | tcl/pkgs/thread2.8.7/ |
145+
| 2 | tcl | tcl/pkgs/thread2.8.7/tcl/ |
146+
| 2 | cmdsrv | tcl/pkgs/thread2.8.7/tcl/cmdsrv/ |

0 commit comments

Comments
 (0)