首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

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

数据库的查询条件
我现在有一个表 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' 

热点排行