首页 > 代码库 > MyBatis Like

MyBatis Like

MySQL:

<select id="listByPidsLikeName" resultType="com.xdt.ibs.environ.device.bean.Environ">
        SELECT id,pid,logicid,`name`,`type`,ip_addr AS ipAddr,`port`,modbus_addr AS modbusAddr,pm25_h AS pm25H,
      pm10_h AS pm10H,temp_h AS tempH,humi_h AS humiH,co2_h AS co2H,tvoc_h AS tvocH,conn_status AS connStatus,
      update_time AS updateTime,create_time AS createTime FROM environ WHERE pid IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> <if test="name != null and name != ‘‘"> AND `name` like CONCAT(‘%‘,#{name},‘%‘) </if> </select>

啦啦啦

MyBatis Like