26CRUD操作之inSQL---嵌套查询

 @Test
    void testInSQL(){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.inSql("id", "select id from tb_user where id < 10");
        wrapper.inSql("age", "select age from tb_user where age > 3");
        System.out.println(userMapper.selectList(wrapper));
    }

sql语句如下
SELECT id,username,password,name,age,email,create_time,update_time,version,status,parentage,del FROM tb_user WHERE del=0 AND (id IN (select id from tb_user where id < 10) AND age IN (select age from tb_user where age > 3))

26CRUD操作之inSQL---嵌套查询

上一篇:注意地理数据库中保留关键字


下一篇:MySQL8.0-练习制作大学生手游情况调查系统2