mysql - How apply SQL LIMIT for a three structure data? -
i utilize famous method showing 3 comment sql. how can display first 3 root comment sub-comment?
i tried create like:
select * names order pid limit 3 asc, id asc limit 3
but limit not supported sql each order by
the illustration can see here: http://sqlfiddle.com/#!2/a593d/4
more clear illustrated in loaded image
try below query
select * names inner bring together (select pid names grouping pid order pid limit 3) my_table using (pid)
demo
mysql sql tree binary-tree
No comments:
Post a Comment