读书人

数据库的查询条件解决方案

发布时间: 2012-07-19 16:02:20 作者: rapoo

数据库的查询条件
我现在有一个表 table 传入两个参数 例如2012-1 2012-3

id year Month
1 2012 1
2 2012 2
3 2012 3
4 2012 4

我根据 那2个参数 在2012-1 和2012-3 之间的数据

求指教

[解决办法]
先拼起来,再比较

SQL code
select id,year+month as ym from table where ym>'2012-1' and ym<'2012-3'
[解决办法]
SQL code
select id,year+'-'+month as ym from table where ym>'2012-1' and ym<'2012-3'
[解决办法]
SQL code
select id,year+month as ym from table where year+month>'2012-1' and year+month<'2012-3' 

读书人网 >C#

热点推荐