有表如下
姓名 Month Day
张三 8 11
张三 8 2
张三 8 3
张三 8 4
李四 9 11
李四 9 13
李四 9 15
孙六 10 1
李四 10 22
现要查出Month >= 8 并且 day > 11 并且 Month <= 10 and days < 4 之间所所有数据(相当于日期在8-11到10-4之间) .请问一下这个where条件要怎样写.where (month >=8 and day >= 10) and (month <= 9 and days <= 20) 这样能查出数据,如果成了 (month >=8 and day >= 10) and (month <= 9 and days <= 5)就没数据出来了.
姓名 Month Day
张三 8 11
张三 8 2
张三 8 3
张三 8 4
李四 9 11
李四 9 13
李四 9 15
孙六 10 1
李四 10 22
现要查出Month >= 8 并且 day > 11 并且 Month <= 10 and days < 4 之间所所有数据(相当于日期在8-11到10-4之间) .请问一下这个where条件要怎样写.where (month >=8 and day >= 10) and (month <= 9 and days <= 20) 这样能查出数据,如果成了 (month >=8 and day >= 10) and (month <= 9 and days <= 5)就没数据出来了.
解决方案 »
- 错误:Cannot resolve collation conflict for equal to operation.
- 这个蛮怪的,老算出来不对。请看看啊。
- null字段能否建立索引?
- 高分在线急求一sql语句优化
- SQL Server2000中复制(Replication)起什么作用,在什么情况下我们可以用到!
- 从ORACLE导入SQL2005,记录中中文为乱码,改了排序规则还是没有变化
- sqlserver触发器的问题
- 请教MS SQL数据库批量改某个表值问题
- 请问如果将一个ID组传给存储过程
- edit控件里的数据怎样与sql server7.0中的整型进行加减,比较大小等操作?
- MS sql2000 系统问题
- 一个Sql存储过程,请教一下老师
还是转化成日期好一点
where '2000-'+Convert(nvarchar,month)+'-'+Convert(nvarchar,day) between '2000-8-11' and '2000-10-4'
where month >= 8 and day > 4 and mont <= 10 and day < 11
select * from table
where month=8 and day>= 10
union
select * from table
where month>8 and month<11
union
select * from table
where month=11 and day<=4
如果第二day 1的话就查不出数据了
insert @Test
select '张三',8,11
union all select '张三',8,2
union all select '张三',8,3
union all select '张三',8,4
union all select '李四',9,11
union all select '李四',9,13
union all select '李四',9,15
union all select '孙六',10,1
union all select '李四',10,22select * from @Test where
--Month >= 8 并且 day > 11
replicate('0', 2- len(cast(Month as varchar(2)))) + cast(Month as varchar(2)) > '0811' and
--Month <= 10 and day < 4
replicate('0', 2- len(cast(Day as varchar(2)))) + cast(Day as varchar(2)) < '1004'