Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

order child below the parent in mysqli

# If no-parent = 0 instead of null 
SELECT CONCAT(IF(parent = 0,'',CONCAT('/',parent)),'/',id) AS gen_order
FROM table 
ORDER BY gen_order

#and if no-parent = null
ORDER BY COALESCE(parent, id), parent IS NOT NULL, id
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #order #child #parent #mysqli
ADD COMMENT
Topic
Name
9+9 =