ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

QueryWrapper获取另一个表的字段

2021-04-08 11:01:18  阅读:10  来源: 互联网

标签:real QueryWrapper queryWrapper 一个 u1 u2 获取 id SELECT


 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.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");

标签:real,QueryWrapper,queryWrapper,一个,u1,u2,获取,id,SELECT
来源: https://www.cnblogs.com/chenlijing/p/14631238.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有