日期:2014-05-18 浏览次数:20481 次
path ------------- 1 1-2 1-2-3 1-2-3-4 a a-b a-b-c a-b-d a-e 我要的结果 /* path ------------- 1-2-3-4 a-e a-b-c a-b-d */
--> 测试数据:@tb declare @tb table([path] varchar(7)) insert @tb select '1' union all select '1-2' union all select '1-2-3' union all select '1-2-3-4' union all select 'a' union all select 'a-b' union all select 'a-b-c' union all select 'a-b-d' union all select 'a-e' select * from @tb AS A WHERE NOT EXISTS(SELECT * FROM @tb WHERE path LIKE A.path + '_%')