i have MYSQL Skillz, BUT this is a lil bit to heavy for me...
I have this DB Structure:
and I want to get alle childs, grandChilds, grandGrandChilds etc etc of a given parent.
example:
when I select the parent 189 as starting point i want to get this result of Ids here:
id {234, 235, 238, 239, 240, 245, 246, 2037, 2038}
and my approach was this here:
SELECT GROUP_CONCAT(lv SEPARATOR ',') FROM (
SELECT @pv:=(SELECT GROUP_CONCAT(id SEPARATOR ',') FROM companies
WHERE parent IN (@pv)) AS lv FROM companies
JOIN
(SELECT @pv:=189)tmp
WHERE id IN (@pv)) a;
But then i only get this result here: IDs:{234,235,246,238,240}
So some of them are missing....
Is there any other possibility to get really all childs of a given parent node?
Thank you so much for any hints...
EDIT: ok i have read that this is not possible in mysql (less then mysql 8.0) so we are using a lower version atm)
but i am scripting in PHP, maybe I can find a solution programatically instead of building a huge sql query....