First off all, english is not my first language. So, sorry if a make any mistakes.
I did a query in MySQL to find the nodes in a hierarchytree table and found something like this (Table1) like this:
Hierarchy1id | Hierarchy 2id| Hierarchy3id| Hierarchy4id| Hierarchy5id
1 2
1 2 3 4
1 2 3 4 5
I have another table (Table 2) that is connected to Table 1 like this:
Parameters id | Hierarchy id
1 1
2 2
3 2
4 3
5 4
I want to count how many parameters are in all of hierarchies from table 1. How can i do that?
My sql to find table 1 is like this:
SELECT *
FROM table AS t1
LEFT JOIN table AS t2 ON t2.parent_id = t1.id
LEFT JOIN table AS t3 ON t3.parent_id = t2.id
LEFT JOIN table AS t4 ON t4.parent_id = t3.id
LEFT JOIN table AS t5 ON t5.parent_id = t4.id
WHERE t.1 = 1