当前位置:网站首页>多表操作-子查询
多表操作-子查询
2022-07-05 11:37:00 【汤键.TJ】
目录
基本概念
- 查询语句中嵌套了查询语句,我们就将嵌套的查询称为子查询
常见的三种情况
- 表的数据准备请点击查看
结果是单行单列的
- 作用:可以将查询的结果作为另一条语句的查询条件,使用运算符判断
- 查询语法:
- select 列名 from 表名 where 列名=(select 列名 from 表名 [where 条件]);
- 例:查询年龄最大的用户姓名

-- 查询年龄最大的用户姓名 SELECT name,age FROM user WHERE age=(SELECT MAX(age) FROM user);结果是多行单列的
- 作用:可以作为条件,使用运算符in或not in进行判断
- 查询语法:
- select 列名 from 表名 where 列名 [not] in (select 列名 from 表名 [where 条件])
- 例:查询张三和李四的订单信息

-- 查询张三和李四的订单信息 SELECT * FROM orderlist WHERE uid IN (SELECT id FROM user WHERE name IN ('张三','李四'));
结果是多行多列的
- 作用:查询的结果可以作为一张虚拟表参与查询
- 查询语法:
- select 列名 from 表名 [别名],(select 列名 from 表名 [where 条件]) [别名] [where 条件];
- 例:查询订单表中id大于4的订单信息和所属用户信息

-- 查询订单表中id大于4的订单信息和所属用户信息 SELECT u.name, o.number FROM user u, (SELECT * FROM orderlist WHERE id>4) o WHERE o.uid=u.id;
边栏推荐
- Web API configuration custom route
- 15 methods in "understand series after reading" teach you to play with strings
- [configuration method of win11 multi-user simultaneous login remote desktop]
- Sklearn model sorting
- 百问百答第45期:应用性能探针监测原理-node JS 探针
- How does redis implement multiple zones?
- COMSOL--三维图形的建立
- 1.php的laravel创建项目
- ACID事务理论
- Cdga | six principles that data governance has to adhere to
猜你喜欢

NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?

How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
![[upsampling method opencv interpolation]](/img/6b/5e8f3c2844f0cbbbf03022e0efd5f0.png)
[upsampling method opencv interpolation]

idea设置打开文件窗口个数

紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成

redis主从模式

splunk配置163邮箱告警

COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics

一次生产环境redis内存占用居高不下问题排查

【上采样方式-OpenCV插值】
随机推荐
MySQL statistical skills: on duplicate key update usage
【yolov5.yaml解析】
Shell script file traversal STR to array string splicing
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
redis的持久化机制原理
pytorch-线性回归
XML解析
基于Lucene3.5.0怎样从TokenStream获得Token
redis 集群模式原理
技术管理进阶——什么是管理者之体力、脑力、心力
无线WIFI学习型8路发射遥控模块
PHP中Array的hash函数实现
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
12. (map data) cesium city building map
ZCMU--1390: 队列问题(1)
高校毕业求职难?“百日千万”网络招聘活动解决你的难题
1.php的laravel创建项目
yolov5目標檢測神經網絡——損失函數計算原理
中非 钻石副石怎么镶嵌,才能既安全又好看?


