I have a table transaction
:
ID AMOUNT PARENT_ID
8135124 1,56 NULL | ON CHAIN 1
8135125 0,02 8135124 | ON CHAIN 1
8135126 1,09 8135124 | ON CHAIN 1
8135127 0,03 8135126 | ON CHAIN 1
8135128 0,47 8135124 | ON CHAIN 1
8135129 1,00 NULL | OTHER CHAIN
8135130 0,01 8135129 | OTHER CHAIN
I'm trying without success get the complete chain of a given transaction. For example, when give 8135126 the return of the query must be all columns of transaction
of 8135124, 8135125, 8135126, 8135127 and 8135128 transactions. The same result when give 8135125 or any other link from chain.
Notice that 8135125, 8135126, and 8135128 are children of 8135124 but, 8135127 is child of 8135126.
How to make it in MySQL?