I have a table with the following columns
id | parent_customer_id
-----------------------------
1 | 0
2 | 0
3 | 1
4 | 2
5 | 4
6 | 4
I'd like a script that can return all the child ids of a certain customer. For example
get_child_ids (1) = 1,3
get_child_ids(2) = 2,4,5,6
get_child_ids(3) = 3
get_child_ids(4) = 4,5,6
get_child_ids(5) = 5
get_child_ids(6) = 6
Some ids could go up to 10 levels deep. I found a great solution to getting parent ids at https://explainextended.com/2009/07/20/hierarchical-data-in-mysql-parents-and-children-in-one-query/ but I'm having trouble getting the children