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

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