SQL tree traversal

I'm not quite sure what I will call this right, but please bear with me.

I am wondering if it is possible to do something similar in SQL (MySQL specifically): Let's say we have tree-like data that is stored in a 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    |                |

Thus, each row has a parent, with the exception of the root string, and each row has children except the rows in the worksheet.

Is it possible to find all the descendants of any given string using only SQL?

+3
source share
3 answers

, SQL, . , ; , , .

, , SQL-. . SQL PHP.

SQL- (, PostgreSQL), MySQL .

+8
0

Source: https://habr.com/ru/post/1766675/


All Articles