日期:2014-05-17 浏览次数:20521 次
declare @A table(MIL varchar(10)) insert into @A select 1 union all select 2 union all select 3 union all select 4 union all select 1 union all select 2 union all select 2 union all select 3 union all select 5 union all select 6 union all select 7 union all select 6 union all select 5 union all select 4 union all select '' --查询大于2且小于5,和小于4的记录 select * from @A where MIL between 2 and 5 union all select * from @A where MIL<4 --查询大于空 and 小于等于5的记录 select * from @A where MIL>'' and MIL<=5 /* (15 行受影响) MIL ---------- 2 3 4 2 2 3 5 5 4 1 2 3 1 2 2 3 0 (17 行受影响) MIL ---------- 1 2 3 4 1 2 2 3 5 5 4 0 (12 行受影响) */
------解决方案--------------------
每一种情况单独写一个查询语句,然后union all。是不是你要的结果?