当前位置:网站首页>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-table gets the data attribute of a row in the read data table

empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),

cookie和session区别

CISP-PTE真题演示
502 bad gateway原因、解决方法

El - table column filter functions, control columns show and hide (effect and easy to implement full marks)

【EA Price strategy OC1】以实时价格为依据的EA,首月翻仓!】

el-table获取读取数据表中某一行的数据属性

10 common data types in MySQL

el-table实现列筛选功能,控制列的显示和隐藏(实现简单,效果满分)
随机推荐
我国有关信息方面的法律法规
MySQL的触发器
置顶文章-
【云原生 · Kubernetes】搭建Harbor仓库
502 bad gateway原因、解决方法
信息学奥赛一本通T1453:移动玩具
信息学奥赛一本通T1448:深搜的剪枝技巧 电路维修
UniApp 自定义条件编译详细使用流程
关于Attention的超详细讲解
你真的了解volatile关键字吗?
一文读懂PCB品质体系认证
PCB 多层板为什么都是偶数层?
El - table column filter functions, control columns show and hide (effect and easy to implement full marks)
Shell脚本--信号发送与捕捉
MySQL忘记密码怎么办
sql优化常用的几种方法
Autowired注解与Resource注解的区别
UniApp scroll-view 事件不生效(@scroll、@scrolltolower、@scrolltoupper ...)
mysql or语句的优化
mysql的配置文件(my.ini或者 my.cnf)所在位置