当前位置:网站首页>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;
边栏推荐
- Unity Xlua MonoProxy Mono代理类
- 汉诺塔问题思路的证明
- Halcon 模板匹配实战代码(一)
- redis主从中的Master自动选举之Sentinel哨兵机制
- yolov5目标检测神经网络——损失函数计算原理
- Implementation of array hash function in PHP
- [calculation of loss in yolov3]
- How to understand super browser? What scenarios can it be used in? What brands are there?
- How does redis implement multiple zones?
- Project summary notes series wstax kt session2 code analysis
猜你喜欢
随机推荐
Riddle 1
Pytorch linear regression
石油化工企业安全生产智能化管控系统平台建设思考和建议
Web API configuration custom route
Reading notes of growth hacker
Pytorch weight decay and dropout
[LeetCode] Wildcard Matching 外卡匹配
Prevent browser backward operation
ibatis的动态sql
Evolution of multi-objective sorting model for classified tab commodity flow
COMSOL -- 3D casual painting -- sweeping
C#实现WinForm DataGridView控件支持叠加数据绑定
Hash tag usage in redis cluster
pytorch-多层感知机MLP
Redis集群(主从)脑裂及解决方案
《看完就懂系列》15个方法教你玩转字符串
COMSOL -- establishment of 3D graphics
How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
Idea set the number of open file windows
7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow