Answer the question
In order to leave comments, you need to log in
How to get data in the form of a graph from a database (sql)?
There is data. Where value is the target data, and prew and next are the data in what order they are.
| value | prew | next |
| 1 | 5 | 6 |
| 2 | 4 | 3 |
| 3 | 2 | 5 |
| 4 | 0 | 2 |
| 5 | 3 | 1 |
| 6 | 1 | null |
| value | prew | next |
| 4 | 0 | 2 |
| 2 | 4 | 3 |
| 3 | 2 | 5 |
| 5 | 3 | 1 |
| 1 | 5 | 6 |
| 6 | 1 | null |
Answer the question
In order to leave comments, you need to log in
Look towards recursive common table expressions:
https://habr.com/post/43955/
https://docs.microsoft.com/ru-ru/sql/t-sql/queries...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question