【MyBatis】动态 SQL

转载:

目录

==========================================

1、if

2、choose when otherwise

3、trim where set

4、foreach

5、bind

==========================================

1、if

    <select id="selectAuthor" resultType="Author">
select * from author where sex = 'male'
<if test="name != null">
and name = #{name}
</if>
</select>

5、bind

基本参数

public List<Blog> selectBlogList(@Param("title") String title);
    <select id="selectBlogList" resultType="Blog">
<bind name="titlePattern" value="'%' + title + '%'"/>
select * from blog
<where>
<if test="title != null">
and title like #{titlePattern}
</if>
</where>
</select>

对象参数

public List<Blog> selectBlogList(Blog blog);
<select id="selectBlogList" resultType="Blog">
<bind name="titlePattern" value="'%' + _parameter.getTitle() + '%'"/>
select * from blog
<where>
<if test="title != null">
and title like #{titlePattern}
</if>
</where>
</select>

最新文章

  1. Head First设计模式之策略模式(Strategy Pattern)
  2. linux系统性能调优第一步——性能分析(vmstat)
  3. POJ 3565 Ants (最小权匹配)
  4. MT4平台上mql4实现的基于macd指标的智能交易EA
  5. 小学生玩ACM----广搜
  6. 8 个实用的 Linux netcat 命令示例
  7. Selenium Webdriver firefox 浏览器问题
  8. sqlserver 操作xml
  9. HDU 2489 Minimal Ratio Tree 最小生成树+DFS
  10. Hadoop(八)Java程序访问HDFS集群中数据块与查看文件系统
  11. ubuntu下安装无界面浏览器
  12. CentOS 7从Python 2.7升级至Python3.6.1
  13. 我们为什么要学习 Spring Boot
  14. 解决Win10 Virtualbox5.2.18桥接不能联网小记
  15. Mini-Batch 、Momentum、Adam算法的实现
  16. windows下安装mingw-w64
  17. 再读c++primer plus 001
  18. yield学习
  19. 同台服务器 部署多个tomcat 需要做的修改
  20. 【树状数组】【P2345】 奶牛集会

热门文章

  1. Elasticsearch系列---常见搜索方式与聚合分析
  2. opencv 6 图像轮廓与图像分割修复 2 使用多边形将轮廓包围
  3. Bootstrap中手指控制轮播图切换
  4. 你必须知道的容器日志 (1) Docker logs &amp; logging driver
  5. Missing radix parameter 错误的解决办法
  6. 解决django或者其他线程中调用scrapy报ReactorNotRestartable的错误
  7. Linux root设置初始值的方法
  8. 洛谷P2634 聪聪可可 (点分治)
  9. sql语句执行步骤详解
  10. Prometheus PromQL 基础