Answering questions asked on the site.
James asks:
Your series on hierarchical queries in MySQL is tremendous! I’m using it to create a series of threaded conversations.
I’m wondering if there is a way to paginate these results.
Specifically, let’s say I want to limit the conversations to
return 10 root nodes (parent=0) and
all of their children in a query.
I can’t just limit the final query, because that will clip off
children. I’ve tried to add LIMITs to your stored
functions, but I’m not getting the magic just right.
How would you go about doing this?
A quick reminder: MySQL does not support
recursion (either CONNECT BY style or recursive
CTE style), so using an …