五、動態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