/**
* 分页分表模糊查询
* @param name
* @param productNo
* @return
*/
@Select("select a.id,a.name, a.product_no productNo,b.name category,a.description from t_product a join t_type b on a.type_id=b.id where a.status=1 and a.product_no like '%${productNo}%' and a.`name` like '%${name}%'")
List<Product> multiselectAllProduct(@Param("name") String name,@Param("productNo") String productNo);
```若传入参数 name 为null 则 拼接的sql语句如下
@Select("select a.id,a.name, a.product_no productNo,b.name category,a.description from t_product a join t_type b on a.type_id=b.id where a.status=1 and a.product_no like '%${productNo}%' and false"
"and false 在拼接时会被自动省略"
can数为null 会怎么拼接到sql语句
最新推荐文章于 2024-04-23 23:53:29 发布
这篇博客探讨了如何在Java中实现分页和分表的模糊查询,特别是当查询参数为空时的处理方式。示例代码展示了一个使用MyBatis的@Select注解来构建SQL查询,该查询在产品名称和编号上进行模糊匹配,同时在参数为空时能正确地忽略无效条件。
9648

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



