<!-- oracle 注意concat括号的书写位置-->
<select id="searchUserBySearchName" parameterType="java.lang.String" resultType="com.urm.entity.User"> select * from t_user where user_name like CONCAT(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>
自己用的是sql server,可以使用