mybatis_plus拼接sql语句(使用mysql内置函数)

2022-07-13 11:45:14

mysql有许多内置的函数提供给我们使用,如果使用mybatis_plus,我们不需要自己去xml文件中实现sql语句,但是又想用到mysql提供的内置函数,此时mybatis_plus提供了可以拼接sql语句的函数。
TO_DAYS(ctime) mysql提供的内置函数
查询当天的数据,也可以查询前1天的数据等等

    @TestvoidcontextLoads2(){
        EntityWrapper<User> userEntityWrapper= new EntityWrapper<>();
        userEntityWrapper.addFilter("TO_DAYS(`ctime`) = TO_DAYS(NOW()) - 1");
        Integer integer= userDao.selectCount(userEntityWrapper);
        System.out.println(integer);}
  • 作者:村长100
  • 原文链接:https://blog.csdn.net/weixin_44130574/article/details/122923250
    更新时间:2022-07-13 11:45:14