0

I have an adjacency list model table with ID and ParentID columns respectively. Both columns are CHAR(32) as required by the client. There is a FK relationship between them.

Unknown depths of descendants. The database is MySQL and the programming is in PHP.

I'm aware that it's probably impossible to get all descendant ID's of a ParentID from a single SQL query. So I've posted this also in the PHP forum to get some guidance on a looping solution.

I need to get the ID's of ALL descendants (children, grandchildren, great-grandchildren, great-great-... etc) from a given ParentID value.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
user1730452
  • 155
  • 1
  • 8
  • Would [this answer for mysql](https://stackoverflow.com/a/33737203/5459839) answer your question? – trincot Jan 31 '19 at 20:05
  • @Bill Karwin you are quick to call this a duplicate question. It's a repost/reworded/best effort to get an answer to a previous question you deemed a duplicate also. Could your majesty be wrong? Maybe if you slow down at getting attention you could actually be useful here. How else does one get an answer when the 'duplicate' doesn't apply? – user1730452 Jan 31 '19 at 20:44
  • There is no recursive SQL solution for an adjacency list table, except for the recursive CTE in MySQL 8.0, which was the first answer in the duplicate. – Bill Karwin Jan 31 '19 at 21:00

0 Answers0