当前位置:网站首页>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;
边栏推荐
- pytorch-多层感知机MLP
- 一次生产环境redis内存占用居高不下问题排查
- 1. Laravel creation project of PHP
- Pytorch softmax regression
- 简单解决redis cluster中从节点读取不了数据(error) MOVED
- 谜语1
- COMSOL -- 3D casual painting -- sweeping
- 【Win11 多用户同时登录远程桌面配置方法】
- [calculation of loss in yolov3]
- An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
猜你喜欢
13.(地图数据篇)百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换
Pytorch MLP
Splunk configuration 163 mailbox alarm
11. (map data section) how to download and use OSM data
[yolov3 loss function]
splunk配置163邮箱告警
中非 钻石副石怎么镶嵌,才能既安全又好看?
12.(地图数据篇)cesium城市建筑物贴图
[crawler] bugs encountered by wasm
How did the situation that NFT trading market mainly uses eth standard for trading come into being?
随机推荐
2048 game logic
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
[yolov3 loss function]
SET XACT_ABORT ON
Empêcher le navigateur de reculer
Reading notes of growth hacker
【Win11 多用户同时登录远程桌面配置方法】
MySQL 巨坑:update 更新慎用影响行数做判断!!!
Manage multiple instagram accounts and share anti Association tips
【TFLite, ONNX, CoreML, TensorRT Export】
Open3D 欧式聚类
Dynamic SQL of ibatis
871. Minimum Number of Refueling Stops
[yolov5.yaml parsing]
Web API configuration custom route
一次生产环境redis内存占用居高不下问题排查
Principle of persistence mechanism of redis
1个插件搞定网页中的广告
谜语1
What does cross-border e-commerce mean? What do you mainly do? What are the business models?