表結構
欄位1 欄位2
1 02 1
3 14 2
5 26 4
//根據父id查詢子id
public static arraylist getallsubcateidfromparentcateid(string parentid) throws exception
db.close();
return list;
}//獲得當前欄目id下的所有子欄目
public static stringbuffer getallsubcateid(string parentid) throws exception else else
//把下一層的所有子結點壓入堆疊
for(int u=1;u<=step;u++)}}
}str = new stringbuffer(str.substring(0,str.lastindexof(",")));
return str;
}修改了點錯誤,這個演算法有點慢……聽說二叉樹排序會快點……有機會再改。
資料庫遞迴查詢
今天工作看同事 用到了start with.connect by prior,不知道什麼意思,查詢了一些資料,以下是比較好理解的。oracle中的select語句可以用start with.connect by prior子句實現遞迴查詢,connect by 是結構化查詢中用到的,其基本語法是 s...
資料庫sql遞迴
假設現在有表student id 主鍵 name 名字 pid 父節點 關聯主鍵 sqlserver 查詢id為1的資料的所有子節點 with functiontable as select from student id 1 uninon all select student.from stude...
資料庫遞迴查詢(CET)
if object id ta isnotnull droptable ta go createtableta id int,name nvarchar 4 parentid nvarchar 2 go insertintota select1,河北省 0 unionall select2,邢台市 ...