www.ctrt.net > mysql递归查询子节点

mysql递归查询子节点

--创建表DROP TABLE IF EXISTS `t_areainfo`;CREATE TABLE `t_areainfo` ( `id` int(11) NOT '0' AUTO_INCREMENT, `level` int(11) DEFAULT '0', `name` varchar(255) DEFAULT '0', `parentId` int(11) DEFAULT '0', `status` int(11) DEFAULT '...

java版的实际例子。类同你说的情况 private void findChildList(AssetType parent,List list){ String hql = "from AssetType a where a.parentAssetType.assetTypeId=? ORDER BY a.sort,a.assetTypeName asc"; List childList = this.assetType...

用函数做,根据你的表结构改: 父节点查询子节点 create function GetChildID(@ParentID int) returns @t table(ID int) as begin insert into @t select id from table where parent_id = @ParentID while @@rowcount0 begin insert into @t se...

给你个网上写的比较好的例子: 方法一:利用函数来得到所有子节点号。 创建一个function getChildLst, 得到一个由所有子节点号组成的字符串. mysql> delimiter // mysql> mysql> CREATE FUNCTION `getChildLst`(rootId INT) -> RETURNS varchar(...

[sql] view plain copy CREATE FUNCTION `getChildList`(rootId INT) RETURNS varchar(1000) BEGIN DECLARE sChildList VARCHAR(1000); DECLARE sChildTemp VARCHAR(1000); SET sChildTemp =cast(rootId as CHAR); WHILE sChildTemp is not null...

java版的实际例子。类同你说的情况 private void findChildList(AssetType parent,List list){ String hql = "from AssetType a where a.parentAssetType.assetTypeId=? ORDER BY a.sort,a.assetTypeName asc"; List childList = this.assetType...

mysql中没有递归删除语句。需要用存储过程。 http://blog.csdn.net/ACMAIN_CHM/article/details/4142971

换个思路吗,不要把自己弄进死胡同 一级一级取不更好,鼠标轻轻一点,一个request就sent了,回头,response一个级别多好

function myfun($id) { $sql = "select `path` from `table` "; $rs = mysql_query($sql); while($rs =mysql_fetch_array($rs)){ $arr[]=explode('-',$rs); } $sql = "select $id from `table` "; $rs = mysql_query($sql); foreach($arr as $va...

你能说的详细一点吗,反正我没有看明白

网站地图

All rights reserved Powered by www.ctrt.net

copyright ©right 2010-2021。
www.ctrt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com