错误写法
select count(goods_code) from ym_goods_info where goods_code like '%',#{goodsCode},'%'
更正写法
select count(goods_code) from ym_goods_info where goods_code like CONCAT(CONCAT('%', #{goodsCode}), '%');mybatis 中使用模糊查询语句
最新推荐文章于 2024-02-15 17:20:57 发布
本文介绍了一种常见的SQL查询错误及其修正方法。错误在于使用了不正确的字符串拼接方式来实现模糊查询,正确的做法是利用CONCAT函数来构建带有通配符的LIKE子句。

5897

被折叠的 条评论
为什么被折叠?



