首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

用sql兑现递归的查询

2012-12-18 
用sql实现递归的查询?? ? ??主键 ? ?父节点 ? ? 是否 ? ? 名称 ? ? ? ? ? ?描述? ? ? ? ? ? ? ? ? ? ? ? ?

用sql实现递归的查询

?

? ? ??主键 ? ?父节点 ? ? 是否 ? ? 名称 ? ? ? ? ? ?描述

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 叶子

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 节点 ? ?

? ? RES_CAT_ID ? ??IS_LEAFNODE

?11_F10农业科学 农业科学 006-12月-12 03.52.09.074000 下午

?31_F10植物保护 植物保护 006-12月-12 03.52.34.545000 下午

?41_F10农作物农作物006-12月-12 03.52.50.804000 下午

?5111农业基础学科农业基础学科006-12月-12 03.53.24.490000 下午

?6111植物保护植物保护006-12月-12 03.53.43.328000 下午

?7211土壤学土壤学007-12月-12 10.34.10.163000 上午

?81_F11畜牧学畜牧学007-12月-12 10.38.43.331000 上午

21_F10农业基础科学 农业基础科学 006-12月-12 03.52.23.398000 下午

? ? ? ? ? ??RES_CAT_PAR_ID第一列:RES_CAT_ID ? 第二列:RES_CAT_PAR_ID ? 第三列 :?IS_LEAFNODE
查询某节点的所有叶子节点的数据select t.res_cat_id, t.res_cat_name, t.res_cat_par_id? from irc_res_cat t?where t.res_cat_id <> '2'??start with t.res_cat_id = '2'connect by prior t.res_cat_id = t.res_cat_par_id? ? ? ?and t.is_del = '0'? ? ? ?and t.is_leafnode = '1'查询根目录下所有的叶子节点数据select t.res_cat_id, t.res_cat_name, t.res_cat_par_id? from irc_res_cat t? where t.res_cat_par_id = '1_F' and t.is_leafnode = '1'

?

热点排行