sql 使用with as 查询所有子类(with as 提高查询性能)
分类:sql server 人气:864 评论:0 时间:2010-08-26 13:51
SQL例:
with C as(
select cid,categoryname,parentid from 表 where cid= 1
union all
select x.cid,x.categoryname,x.parentid from 表 x,C
where x.parentid=C.cid
)
select * from C