NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
~~~ 和 Java 中的 switch语句相似,MyBatis 提供 choose 元素。 <!-- 动态sql 之choose when otherwise 注意 choose只选择一次。如果所有when都不满足的时候,otherwise中的内容才会被拼接 --> <select id="selDS2" resultType="cn.li.pojo.Employee"> select * from employee where 1=1 <choose> <when test="name!=null"> and name like '%${name}%' </when> <when test="address!=null"> and address='${address}' </when> <otherwise> order by name </otherwise> </choose> </select> ~~~