首页 > 数据库技术 > 详细

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

时间:2014-10-17 23:26:15      阅读:819      评论:0      收藏:0      [点我收藏+]
	
<!-- 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模糊查询

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!