ibatis动态SQL使用如何通过IBATIS动态Sql实现两个日期之间

时间:2016-08-08 13:23:25

标签: dynamic-sql ibatis

我想在Ibatis中做一个复杂的动态选择语句,就像这样

select * from emp 
//when dateParam between 2012-03-1 and 2013-03-01 then
union
select * from emp1
//when dateParam between 2014-03-1 and 2015-03-01 then
union
select * from emp2

1 个答案:

答案 0 :(得分:0)

我这样做:

select * from emp  
<isLessEqual  property="dateParam" compareValue="2015-03-01">
  union
  select * from emp1
</isLessEqual>
<isLessEqual  property="dateParam" compareValue="2013-03-01">
  union
  select * from emp1
</isLessEqual>