mybatis如何进行like模糊查询?

2026-02-17 20:14:05

1、使用bind标签:

 <if test="params.ewbNo!=null">

             <bind name="pattern" value="'%' + params.ewbNo +'%'" />

       毙霜亲    and e.ewb_no like #{pattern}

 </if>

mybatis如何进行like模糊查询?

2、在代码参数中直接加入%%:

params.put("ewbNo","%"+request.getStringValue("ewbNo")+"%");

mybatis如何进行like模糊查询?

3、在sql语句中进行使用concat连接互眠

<if test="params.ewbNo!=null">    e.ewb_no LIKE concat(concat('%',#{params.ewbNo}),'%')</if>

mybatis如何进行like模糊查询?

4、使用bind结果查看。

mybatis如何进行like模糊查询?

5、使用在代码参数中直接加入%%查看输出sql

mybatis如何进行like模糊查询?

6、使用concat查看输出的sql结果晃散。

mybatis如何进行like模糊查询?

猜你喜欢