Rumah >pangkalan data >tutorial mysql >建立一个高效的树表 Tree Table
打开此地址查看, 永久有效 ,老手绕行 领接表增强 + MPTT 两种模式 http://mat1.gtimg.com/hb/js/common/demo/tree.html 超快查询所有子孙 画个table,写了样式,居然被替换的面目全非,所以,干脆做成HTML算了。 无 查询子集SELECT * FROM `table` WHERE `p
打开此地址查看, 永久有效 ,老手绕行查询子集 SELECT * FROM `table` WHERE `pid` = 3 查询子孙集 SELECT * FROM `table` WHERE `place` LIKE '%/3/%' 查询某代子集 SELECT * FROM `table` WHERE `place` LIKE '%/3/%' AND `level` = 4 插入 $insert_id = INSERT INTO `table` (`name`,`pid`) VALUES('面试专员','10') $parent = SELECT * FROM `table` WHERE `id` = 10 UPDATE `table` SET `place` = '{$parent['place']}{$insert_id}/',`level`= {$parent['level']} + 1 WHERE `id` = {$insert_id} 修改父级 $parent = SELECT * FROM `table` WHERE `id` = {$pid} UPDATE `table` SET `pid` = {$pid},`place` = '{$parent['place']}{$insert_id}/',`level`= {$parent['level']} + 1 WHERE `id` = {$id}