有一段sql语句如下 这是 我传了style情况下的sql
select a.name,b.sex from tableA a,tableB b where a.id=b.id and a.style=#style# order by a.age limit #limit#
我想把他变成动态的配置 当style 不存在的情况下sql为
select a.name,b.sex from tableA a,tableB b where a.id=b.id  order by a.age limit #limit#
试了用dynamic isNotNull  来配置  就是不行
希望CSDN 的大牛 能帮帮忙 这里应该怎么配置 用include?

解决方案 »

  1.   

    <isNotNull property="style">
    </isNotNull>
    <isNull property="style">
    </isNull>
      

  2.   

    配置有问题么select a.name,b.sex from tableA a,tableB b where a.id=b.id
    <dynamic prepend="and">
       <isNotNull property="style">
         a.style=#style#
       </isNotNull>
    </dynamic>
    order by a.age limit #limit#
      

  3.   

    select 
           a.name,b.sex from tableA a,tableB b 
        <dynamic prepend="WHERE">       <isNotNull prepend="AND" property="style">
             a.style = #style#
           </isNotNull>    </dynamic>还有很多的参数设置,例如:参数等于多少,参数不等于0等等