order child below the parent in mysqli

Solutions on MaxInterview for order child below the parent in mysqli by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "order child below the parent in mysqli"
Syrine
18 Jan 2020
1# If no-parent = 0 instead of null 
2SELECT CONCAT(IF(parent = 0,'',CONCAT('/',parent)),'/',id) AS gen_order
3FROM table 
4ORDER BY gen_order
5
6#and if no-parent = null
7ORDER BY COALESCE(parent, id), parent IS NOT NULL, id