当前位置:网站首页>Multi table operation - sub query
Multi table operation - sub query
2022-07-05 11:47:00 【Soup key TJ】
Catalog
The result is a single row, single column
The result is multi row, single column
The result is multi row, multi column
Basic concepts
- The query statement is nested in the query statement , We will call the nested query sub query
Three common situations
- Please click to view the data preparation of the table
The result is a single row, single column
- effect : The result of the query can be used as the query condition of another statement , Use operators to judge
- The query syntax :
- select Name from Table name where Name =(select Name from Table name [where Conditions ]);
- example : Query the oldest user name

-- Query the oldest user name SELECT name,age FROM user WHERE age=(SELECT MAX(age) FROM user);The result is multi row, single column
- effect : As a condition , Use the operator in or not in Judge
- The query syntax :
- select Name from Table name where Name [not] in (select Name from Table name [where Conditions ])
- example : Check the order information of Zhang San and Li Si

-- Check the order information of Zhang San and Li Si SELECT * FROM orderlist WHERE uid IN (SELECT id FROM user WHERE name IN (' Zhang San ',' Li Si '));
The result is multi row, multi column
- effect : The query result can be used as a virtual table to participate in the query
- The query syntax :
- select Name from Table name [ Alias ],(select Name from Table name [where Conditions ]) [ Alias ] [where Conditions ];
- example : Query the order table id Greater than 4 Order information and user information of

-- Query the order table id Greater than 4 Order information and user information of SELECT u.name, o.number FROM user u, (SELECT * FROM orderlist WHERE id>4) o WHERE o.uid=u.id;
边栏推荐
- [leetcode] wild card matching
- 2048 game logic
- PHP中Array的hash函数实现
- Sentinel sentinel mechanism of master automatic election in redis master-slave
- 15 methods in "understand series after reading" teach you to play with strings
- 1 plug-in to handle advertisements in web pages
- 【L1、L2、smooth L1三类损失函数】
- Sklearn model sorting
- pytorch训练进程被中断了
- Pytorch training process was interrupted
猜你喜欢
随机推荐
Pytorch softmax regression
redis的持久化机制原理
Install esxi 6.0 interactively
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Dynamic SQL of ibatis
Zcmu--1390: queue problem (1)
Advanced technology management - what is the physical, mental and mental strength of managers
1. Laravel creation project of PHP
Empêcher le navigateur de reculer
Question and answer 45: application of performance probe monitoring principle node JS probe
Principle of redis cluster mode
Sklearn model sorting
如何让你的产品越贵越好卖
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in
以交互方式安装ESXi 6.0
【云原生 | Kubernetes篇】Ingress案例实战(十三)
ZCMU--1390: 队列问题(1)
网络五连鞭
[calculation of loss in yolov3]
[upsampling method opencv interpolation]







![[yolov5.yaml parsing]](/img/ae/934f69206190848ec3da10edbeb59a.png)

![[crawler] Charles unknown error](/img/82/c36b225d0502f67cd04225f39de145.png)

