当前位置:网站首页>Laravel 中使用子查询
Laravel 中使用子查询
2022-08-03 05:39:00 【知其黑、受其白】
子查询
子查询(Sub Query),也称作内查询(Inner Query)或嵌套查询(Nested Query),是一种嵌套在其他 SQL 查询的 WHERE 子句中的查询。
自带闭包
User::whereIn('id', function($query){
$query->select('user_id')
->from('admin_user')
->whereIn('type', ['1', '2']);
})->get();
获得的 SQL 如下:
SELECT * FROM `user` where `id` IN (
SELECT `user_id` FROM `admin_user` WHERE `type` IN (1, 2)
);
边栏推荐
- El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
- Docker-compose安装mysql
- 一家可靠的HDI板厂,需要具备哪些基本条件?
- RADIUS计费认证如何配置?这篇文章一步一步教你完成
- UniApp 获取当前页面标题(navigationBarTitleText)
- 5 个开源的 Rust Web 开发框架,你选择哪个?
- Detailed explanation and reproduction of AlexNet network
- 信息学奥赛一本通T1451:棋盘游戏
- AlexNet网络详解及复现
- AutoInt网络详解及pytorch复现
猜你喜欢
随机推荐
Chrome configuration samesite=none method
高密度 PCB 线路板设计中的过孔知识
信息学奥赛一本通T1449:魔板
MySQL的安装教程(嗷嗷详细,包教包会~)
一文读懂PCB品质体系认证
保姆级讲解Transformer
Composer require 报错 Installation failed, reverting ./composer.json and ./composer.lock to their ...
沉铜/黑孔/黑影工艺,PCB该 Pick 哪一种?
【经验分享】配置用户通过Console口登录设备示例
置顶文章-
超全!9种PCB表面处理工艺大对比
el-table获取读取数据表中某一行的数据属性
El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
【Markdown 数学公式】markdown常用公式写法
5 个开源的 Rust Web 开发框架,你选择哪个?
html+css+php+mysql实现注册+登录+修改密码(附完整代码)
FiBiNet torch复现
mysql or语句的优化
ES6中 Symbol 的基础学习,迭代器和生成器的基本用法
empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),









