qq_乖乖想叛逆_0
2021-02-26 15:02
select id,catename,path,concat(path,',',id) as fullpath from likecate where 1 order by fullpath asc;
INSERT INTO likecate VALUES
(1,'','手机',0,0),
(2,'1','功能手机',0,0),
(3,'1,2','老人手机',0,0),
(4,'1,2','儿童手机',0,0),
(5,'1','智能手机',0,0),
(6,'1,5','Android手机',0,0),
(7,'1,5','iOS手机',0,0),
(8,'1,5','winphoto手机',0,0),
(9,'1,2,4','色盲手机',0,0),
(10,'1,2,3','大字手机',0,0),
(11,'12','台式机',0,0),
(12,'','电脑',0,0),/*经过一些增删操作,有可能父类id大于子类id*/
(13,'12,11','一体机',0,0),
(14,'12,11','非一体机',0,0),
(15,'12','笔记本',0,0);
SELECT id,catename,path,IF (path,concat(path, ',', id),id) AS fullpath FROM likecate ORDER BY fullpath ASC;
用if判断更好
PHP无限级分类技术
30076 学习 · 83 问题
相似问题