materialized-path-pattern

how to create tree view in mysql using stored procedure

天大地大妈咪最大 提交于 2020-01-17 14:05:04
问题 I am confused. I don't know how to create a tree view in MySQL using stored procedure. I tried searching in Google and I don't understand how to query. I have deptid | dept_code | dept_name | parent_deptid 1 1 wadir Umum 0 2 101 bagian umum 1 3 10101 kepala umum 2 4 102 bagian privasi 1 5 1010101 SUb bagian Tu 3 6 1010102 bagian umum 3 and I want to make it like this deptid | dept_code | dept_name | parent_deptid 1 1 wadir Umum 0 2 101 -bagian umum 1 3 10101 --kepala umum 2 5 1010101 ---Sub

how to create tree view in mysql using stored procedure

岁酱吖の 提交于 2020-01-17 14:02:15
问题 I am confused. I don't know how to create a tree view in MySQL using stored procedure. I tried searching in Google and I don't understand how to query. I have deptid | dept_code | dept_name | parent_deptid 1 1 wadir Umum 0 2 101 bagian umum 1 3 10101 kepala umum 2 4 102 bagian privasi 1 5 1010101 SUb bagian Tu 3 6 1010102 bagian umum 3 and I want to make it like this deptid | dept_code | dept_name | parent_deptid 1 1 wadir Umum 0 2 101 -bagian umum 1 3 10101 --kepala umum 2 5 1010101 ---Sub

Build tree from materialized path

自古美人都是妖i 提交于 2019-12-22 07:56:15
问题 I have a trouble building a tree structure from materialized path using ruby. Assuming I have a sorted result set (from couchdb): [ { :key => [], :value => "Home" }, { :key => ["about"], :value => "About" }, { :key => ["services"], :value => "Services" }, { :key => ["services", "plans"], :value => "Plans" }, { :key => ["services", "training"], :value => "Training" }, { :key => ["services", "training", "python"], :value => "Python" }, { :key => ["services", "training", "ruby"], :value => "Ruby

Build a JSON tree from materialized paths

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-09 05:49:28
问题 I'm planning on using materialized paths in MongoDB to represent a tree and need to convert the materialized paths back into a JSON tree. ex. // Materialized path var input = [ {"id": "0", "path": "javascript" }, {"id": "1", "path": "javascript/database" }, {"id": "2", "path": "javascript/database/tree" }, {"id": "3", "path": "javascript/mvc" }, {"id": "4", "path": "javascript/mvc/knockout.js"}, {"id": "5", "path": "javascript/mvc/backbone.js"}, {"id": "6", "path": "c++" }, {"id": "7", "path"

Selecting based on path in mysql

我是研究僧i 提交于 2019-12-06 06:12:41
问题 I have a column id , a column parent and a column path that is a materialized path. It looks like 1 | \N | 1 2 | 1 | 1/2 3 | 2 | 1/2/3 4 | 3 | 1/2/3/4 5 | 3 | 1/2/3/5 6 | 2 | 1/2/6 7 | 6 | 1/2/6/7 8 | 2 | 1/2/8 9 | 1 | 1/9 10 | 9 | 1/9/10 11 | 10 | 1/9/10/11 12 | 11 | 1/9/10/11/12 13 | 11 | 1/9/10/11/13 14 | 11 | 1/9/10/11/14 15 | 14 | 1/9/10/11/14/15 16 | 14 | 1/9/10/11/14/16 17 | 14 | 1/9/10/11/14/17 18 | 10 | 1/9/10/18 19 | \N | 19 20 | 19 | 19\20 21 | 19 | 19\21 I need to do some queries

Build tree from materialized path

笑着哭i 提交于 2019-12-05 14:58:14
I have a trouble building a tree structure from materialized path using ruby. Assuming I have a sorted result set (from couchdb): [ { :key => [], :value => "Home" }, { :key => ["about"], :value => "About" }, { :key => ["services"], :value => "Services" }, { :key => ["services", "plans"], :value => "Plans" }, { :key => ["services", "training"], :value => "Training" }, { :key => ["services", "training", "python"], :value => "Python" }, { :key => ["services", "training", "ruby"], :value => "Ruby" } ] I just need this as a tree in ruby,the following hash is good enough: { :title => "Home", :path =

Selecting based on path in mysql

£可爱£侵袭症+ 提交于 2019-12-04 09:35:16
I have a column id , a column parent and a column path that is a materialized path. It looks like 1 | \N | 1 2 | 1 | 1/2 3 | 2 | 1/2/3 4 | 3 | 1/2/3/4 5 | 3 | 1/2/3/5 6 | 2 | 1/2/6 7 | 6 | 1/2/6/7 8 | 2 | 1/2/8 9 | 1 | 1/9 10 | 9 | 1/9/10 11 | 10 | 1/9/10/11 12 | 11 | 1/9/10/11/12 13 | 11 | 1/9/10/11/13 14 | 11 | 1/9/10/11/14 15 | 14 | 1/9/10/11/14/15 16 | 14 | 1/9/10/11/14/16 17 | 14 | 1/9/10/11/14/17 18 | 10 | 1/9/10/18 19 | \N | 19 20 | 19 | 19\20 21 | 19 | 19\21 I need to do some queries based off this table. The queries I need to do are Select all children of id 9 SELECT * FROM `tester`

Sorting tree with a materialized path?

时光怂恿深爱的人放手 提交于 2019-11-27 18:37:20
I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as one would expect with threaded forum replies. id | parent_id | matpath | created ----+-----------+---------+---------------------------- 2 | 1 | 1 | 2010-05-08 15:18:37.987544 3 | 1 | 1 | 2010-05-08 17:38:14.125377 4 | 1 | 1 | 2010-05-08 17:38:57.26743 5 | 1 | 1 | 2010-05-08 17:43:28.211708 7 | 1 | 1 | 2010-05-08 18:18:11.849735 6 | 2 | 1.2 | 2010-05-08 17:50:43.288759 9 | 5 | 1.5 | 2010-05-09 14:02:43.818646 8 | 6 | 1.2.6 | 2010-05-09

Sorting tree with a materialized path?

牧云@^-^@ 提交于 2019-11-26 19:31:37
问题 I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as one would expect with threaded forum replies. id | parent_id | matpath | created ----+-----------+---------+---------------------------- 2 | 1 | 1 | 2010-05-08 15:18:37.987544 3 | 1 | 1 | 2010-05-08 17:38:14.125377 4 | 1 | 1 | 2010-05-08 17:38:57.26743 5 | 1 | 1 | 2010-05-08 17:43:28.211708 7 | 1 | 1 | 2010-05-08 18:18:11.849735 6 | 2