select name,class_name,address from info_table where concat(name,class_name,address) like oncat('%','天','%')
关键字多个的情况,需要拼接多条,如下
1 2 3 4 5 6 7 8 9
select name,class_name,address from info_table where concat(name,class_name,address) like oncat('%','天','%') or concat(name,class_name,address) like oncat('%','地','%') or concat(name,class_name,address) like oncat('%','一','%') or concat(name,class_name,address) like oncat('%','号','%')
<selectid="getInfoList"parameterType='com.test.from.InfoForm'resultType='com.test.Info'> SELECT name, class_name, address FROM info_table WHERE is_delete = 0 <iftest="keywords != null and !keywords.isEmpty()"> AND <foreachcollection="keywords"item="keyword"open=""close=""separator=" OR "> CONCAT(name, class_name, address) LIKE CONCAT('%', #{keyword}, '%') </foreach> </if> </select>