0

Suppose I have this table:

A hierarchical table

Now if I need to get the path to the root node from any node , how will I get that ?

Suppose I have searched for id=28, then I want to get (0,19,20) path to root node by parent_id.

Update on Abhik Chakraborty's comment: Please note that , I am not asking for any hierarchical query.

Update on Shadow's Comment : I cannot use procedure that's why I asked for help on query. Please don't answer any stored procedure.

Subhajit
  • 876
  • 3
  • 17
  • 37
  • MySql does not have any hierarchical query, you may do this on application level using recursive function. – Abhik Chakraborty May 30 '17 at 10:28
  • The 1st duplicate link provides you a non-recursive MySQL procedure as a solution, the 2nd duplicate link provides you with more of a theoretical background and lists some alternatives to storing your hierarchical data in an adjacency list format. Verdict is: this is going to be ugly in your current data model. – Shadow May 30 '17 at 10:30
  • Can you please elaborate why this data model is going to be ugly and what will be the better approach. Any help will be highly appreciated. Thanks – Subhajit May 30 '17 at 10:53

0 Answers0