日期:2014-05-16 浏览次数:20693 次
create table book(bookType varchar(100),parent varchar(100))
insert into book
select 'xxx','yyy' union all
select '科幻','xxx' union all
select '穿越','科幻' union all
select '古装','穿越'
go
;with t as
(
select * from book as a where booktype='科幻'
union all
select a.* from book as a inner join t as b on a.parent=b.booktype
)
select * from t
/*
bookType parent
科幻 xxx
穿越 科幻
古装 穿越
*/