I am not totally sure I am naming this right, but please bear with me.
I am wondering if is possible to do something like this in SQL(MySQL specifically):
Let's say we have tree-like data that is persisted in the database in the following table:
mysql> desc data_table;
+------------------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| parent_id | int(10) unsigned | YES | MUL | NULL | |
| value | text | YES | | NULL | |
So each row has a parent, except for the 'root' row and each row has children except for leaf rows.
Is it possible to find all descendants of any given row utilizing solely SQL?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…