日期:2014-05-18  浏览次数:20660 次

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