QueryWrapper获取另一个表的字段

 QueryWrapper<StFloodcollR> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("*,(SELECT u1.real_name FROM `user` u1 WHERE CREATEDBY = u1.id ) AS createdUser,(SELECT u2.real_name FROM `user` u2 WHERE MODIFYBY = u2.id ) AS modifyUser");
        PageHelper.startPage(pageNo, pageSize);
        if (!StringUtils.isEmpty(lunTime)) {

            queryWrapper.ge("LUNTIME", TimeUtil.getStartOfDay(lunTime));
            queryWrapper.le("LUNTIME", TimeUtil.getEndOfDay(lunTime));
        }

第一步:在StFloodcollR实体类中 加入两个

QueryWrapper获取另一个表的字段

 

 第二步:在查询语句中加入

queryWrapper.select("*,(SELECT u1.real_name FROM `user` u1 WHERE CREATEDBY = u1.id ) AS createdUser,(SELECT u2.real_name FROM `user` u2 WHERE MODIFYBY = u2.id ) AS modifyUser");
上一篇:矩阵的复习回顾


下一篇:C语言实现printf的基本格式输出%d,%c,%p,%s