MyBatic:查询语句
1、模糊查询:
1. sql中字符串拼接
SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%');
2. 使用 ${...} 代替 #{...}
SELECT * FROM tableName WHERE name LIKE '%${text}%';
2、数组查询:
select * from rb_borrow_tag rbt where 1=1 <if test="tagIds != null" > and rbt.id in <foreach item="item" index="index" collection="tagIds" open="(" separator="," close=")"> #{item} </foreach> </if> ORDER BY id desc </select>
工作小总结,有错请指出,谢谢。