当前位置:网站首页>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)
);
边栏推荐
- torch.nn.modules.activation.ReLU is not a Module subclass
- PCB制造常用的13种测试方法,你了解几种?
- Composer require 报错 Installation failed, reverting ./composer.json and ./composer.lock to their ...
- 信息学奥赛一本通T1449:魔板
- 连续型特征做embedding代码示例
- RADIUS计费认证如何配置?这篇文章一步一步教你完成
- MySQL中,对结果或条件进行字符串拼接
- 超全!9种PCB表面处理工艺大对比
- Basic syntax of MySQL DDL and DML and DQL
- Getting started with el-tabs (tab bar)
猜你喜欢

torch.nn.modules.activation.ReLU is not a Module subclass

Pinned Articles-
Scala 基础 (三):运算符和流程控制

Redis-记一次docker下使用redis

【云原生 · Kubernetes】Kubernetes简介及基本组件

【云原生 · Kubernetes】搭建Harbor仓库

MySQL的触发器

Nacos下载与安装

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

MySQL的10种常用数据类型
随机推荐
ISIJ 2022收官,中国初中生再展风采
el-table获取读取数据表中某一行的数据属性
Basic syntax of MySQL DDL and DML and DQL
el-tabs(标签栏)的入门学习
Nacos下载与安装
MySQL性能优化(硬件,系统配置,表结构,SQL语句)
El - tree set using setCheckedNodessetCheckedKeys default check nodes, and a new check through setChecked specified node
ES6中 async 函数、await表达式 的基本用法
El - table column filter functions, control columns show and hide (effect and easy to implement full marks)
pyspark---低频特征处理
spark中Repartition 和 Coalesce 区别
SQLServer2019安装(Windows)
pyspark df 二次排序
pyspark @udf 循环使用变量问题
PCB制造常用的13种测试方法,你了解几种?
你真的了解volatile关键字吗?
【IoU loss】IoU损失函数理解
【GIoU loss】GIoU loss损失函数理解
PCB 多层板为什么都是偶数层?
cookie和session区别