SQL Server 之 WITH AS 递归

WITH    Category_Tree
          AS ( SELECT   Code
               FROM     SubjectDB.Supplier.SupplierCategory
               WHERE    Code LIKE '0101%'
             )

SELECT  *
FROM    SubjectDB.Supplier.SupplierCategory
WHERE   Code IN ( SELECT    *
                      FROM      Category_Tree ) 

查询结果:

posted @ 2016-08-30 18:20  DeqiangLee  阅读(684)  评论(0编辑  收藏  举报