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 )
查询结果:
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 )
查询结果: