MyBatis动态sql中模糊查询
来源:互联网 发布:程序员高级证书如何考 编辑:程序博客网 时间:2024/05/12 17:41
1、直接拼接%%:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0<if test="frameNo != null and frameNo != '%%'">
and frame_no like '%${frameNo}%'
</if>
</select>
2、定义 一个<bind/>变量:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
<bind name="frameNo" value="'%' + _parameter.frameNo + '%'" />select <include refid="textDatas"/> from tab_test where is_deleted = 0
<if test="frameNo != null and frameNo != '%%'">
and frame_no like #{frameNo}
</if>
</select>
3、使用locate()函数:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0<if test="frameNo != null and frameNo != ''">
and LOCATE(#{frameNo}, frame_no ) > 0
</if>
</select>
4、使用instr()函数:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0<if test="frameNo != null and frameNo != ''">
and INSTR(frame_no , #{frameNo})
</if>
</select>
阅读全文
0 0
- MyBatis动态sql中模糊查询
- MyBatis动态查询 模糊查询实例sql
- MyBatis-动态sql与模糊查询 -07
- mybatis 动态SQL与模糊查询
- Mybatis 1.动态sql 2.模糊查询
- 03. mybatis 动态sql && 模糊查询
- Mybatis动态SQL与模糊查询
- Mybatis学习----模糊查询和动态sql
- 六、Mybatis动态SQL和模糊查询
- Mybatis之动态SQL 模糊查询
- mybatis的动态SQL与模糊查询
- Mybatis 模糊查询和动态sql语句
- MyBatis的动态SQL的模糊查询
- mybatis中模糊查询sql语句
- mybatis中模糊查询的sql语句
- MyBatis中模糊查询
- Mybatis中模糊查询
- Mybatis中模糊查询
- Activity全屏非全屏的切换
- 自制弹出框--公告消息
- 购物车小做
- iPhone启动图尺寸
- 初学者手绘漫画人物基础教程
- MyBatis动态sql中模糊查询
- C结构体与JAVA类的相互转换
- 测试
- Android RecyclerView 使用完全解析 体验艺术般的控件
- 随机森林
- 国内比较完善的架包jar maven仓库地址!!!
- Json序列话方法
- 同商品多行数据 其中一行选中则其他行也要提示选中
- 枚举类样例Java