C/C++教程

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

本文主要是介绍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---嵌套查询的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!