📜  在 mysqli 中排序子级低于父级 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:21.837000             🧑  作者: Mango

代码示例1
# 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