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

<!-- 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>

上一篇:日志服务中采集k8s时心跳失败基本排查


下一篇:逻辑 STANDBY ORA-00368日志应用失败处理一例