Mybatis注解中使用if标签

在SQL语句中加入script标签

@Select({
            "<script>" ,
            "SELECT COUNT(*) FROM category",
            "<if test='query != null and query != \" \" '>",
            "where cat_name like '%${query}%'",
            "</if>",
            "</script>"
    })
    Integer getCount(@Param("query") String query);
发布了33 篇原创文章 · 获赞 0 · 访问量 368

猜你喜欢

转载自blog.csdn.net/weixin_43596905/article/details/104868105