S
S
strelkovandreyv2019-07-18 08:17:20
MySQL
strelkovandreyv, 2019-07-18 08:17:20

How to build a reverse recursive query in MySQL?

Good afternoon, please tell me if it is possible to build a reverse recursive query in my case.
There is a table
child | parent
1 | null
2 ​​| 1
3 | 2
4 | 3
5 | 4
That is, 5 is associated with 4, 4 with 3, and so on.
I need to make such a request, where I specify 3 for example as an input filter, and I need to get 3 + 4 + 5 as an output, in this form, in one line with a separator + (non-trivial task)
i.e. something like select from hierarchy_view where child = 3
output 3+4+5
using mariadb 10.3.13

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
irishmann, 2019-07-18
@irishmann

Oddly enough, the first link in Google

G
Gomonov, 2019-07-18
@Gomonov

Closure Table

A
Artem Abramovich, 2017-10-24
@fyapy

Because you are using an object call on the page, regular pagination does not work there. You need to use an additional function and pass the paged argument
Detailed guide here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question