Mybatis常用Sql写法
DML(数据操纵语言):
1.模糊查询
示例: <if test="guideDate !=null and guideDate !='' ">
and gu.guideDate like "%"#{guideDate}"%"
</if>
2.精确查询
示例:<if test="status !=null and status !='' ">
and gu.status = #{status}
</if>
3.分页查询(在有分页插件的基础上才可使用,在sql最后加上)
示例:LIMIT ${(page.pageNo - 1) * page.pageSize}, ${page.pageSize}
4.查询日期后:
示例:<if test="map.applyBeginDate != null and map.applyBeginDate != ''">
<![CDATA[ AND b.applyBeginDate >= #{map.applyBeginDate}]]>
</if>
5.查询日期前:
示例:<if test="map.applyBeginDate != null and map.applyBeginDate != ''">
<![CDATA[ AND b.applyBeginDate <= #{map.applyBeginDate}]]>
</if>
6.
DDL(数据定义语言):
示例: <if test="guideDate !=null and guideDate !='' ">
and gu.guideDate like "%"#{guideDate}"%"
</if>
2.精确查询
示例:<if test="status !=null and status !='' ">
and gu.status = #{status}
</if>
3.分页查询(在有分页插件的基础上才可使用,在sql最后加上)
示例:LIMIT ${(page.pageNo - 1) * page.pageSize}, ${page.pageSize}
4.查询日期后:
示例:<if test="map.applyBeginDate != null and map.applyBeginDate != ''">
<![CDATA[ AND b.applyBeginDate >= #{map.applyBeginDate}]]>
</if>
5.查询日期前:
示例:<if test="map.applyBeginDate != null and map.applyBeginDate != ''">
<![CDATA[ AND b.applyBeginDate <= #{map.applyBeginDate}]]>
</if>
6.
DDL(数据定义语言):