mybatis choose when

时间:2025-03-10 08:37:03
<!--多个条件,进行信息查询 -->
<select  resultType="userListArray" >
select * from user where 1=1
<choose>
<when test="userName!=null and userName!='' "> 
            and userName like concat('%',#{userName},'%')
     </when>
<when test="usercode!=null and usercode!='' ">
          and usercode like concat('%',#{usercode},'%')
     </when>
 
<otherwise> 
          and year(creationDate)=year(#{creationDate}) 
    </otherwise>
</choose>
</select>