码迷,mamicode.com
首页 > 数据库 > 详细

Mybatis中oracle、mysql、db2、sql server的like模糊查询

时间:2014-10-17 23:27:29      阅读:565      评论:0      收藏:0      [点我收藏+]

标签:sql server   oracle   mybatis   mysql   db2   

	
<!-- oracle -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like CONCAT('%',#{search_name},'%')
</select>
<!-- 或者 -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like '%'||#{search_name}||'%' 
</select>

<!-- mysql -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like CONCAT('%',#{search_name},'%')
</select>
	
<!-- sql server -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like '%'+#{search_name}+'%'
</select>

<!-- db2 -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like CONCAT('%',#{search_name},'%')  
</select>
<!-- 或者 -->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User">
	select * from t_user where user_name like '%'||#{search_name}||'%' 
</select>

Mybatis中oracle、mysql、db2、sql server的like模糊查询

标签:sql server   oracle   mybatis   mysql   db2   

原文地址:http://blog.csdn.net/responsecool/article/details/40189797

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!