五、动态SQL(


一、<choose><when><otherwise>

这是一套标签, 功能类似于 switch...case...

 1 <select id="sel1" resultType="User">
 2         select * from tb_user
 3         <where>
 4             <choose>
 5                 <when test="user != null and user != ''">
 6                     and user = #{user}
 7                 </when>
 8                 <when test="passwd != null and passwd != ''">
 9                     and passwd = #{passwd}
10                 </when>
11                 <otherwise>
12                     and 1 = 1
13                 </otherwise>
14             </choose>
15         </where>
16 </select>      

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM