当前位置:网站首页>Multi table operation - external connection query
Multi table operation - external connection query
2022-07-04 19:41:00 【Soup key TJ】
Catalog
- External connection query is divided into left external connection query and right external connection query
- Take a table as Lord , Take out all the records in it , Then each one is joined to another table , Whether or not you can match the conditions , In the end, they will keep
- Can match , Keep it right ; Can't match , The fields of other tables are empty (null), Called external connection
The left outer join
- Query principle
- Query all the data in the left table , And the left and right tables have the intersection part of the data
- The query syntax
- select Name from Table name 1 left [outer] join Table name 2 on Conditions
Right connection
- Query principle
- Query all the data in the right table , And the left and right tables have the intersection part of the data
- The query syntax
- select Name from Table name 1 right [outer] join Table name 2 on Conditions
Example operation
- Please click to view the data preparation of the table
- The left outer join
- Query all user information , And the corresponding order information of the user
-- The left outer join -- Query all user information , And the corresponding order information of the user SELECT u.*, o.number FROM user u LEFT OUTER JOIN orderlist o ON o.uid=u.id;
- Right connection
- Query all order information , And the user information of the order
-- Right connection -- Query all order information , And the user information of the order SELECT o.*, u.name FROM user u RIGHT OUTER JOIN orderlist o ON o.uid=u.id;
边栏推荐
- Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
- kotlin 继承
- 测试工程师如何“攻城”(上)
- 【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
- BCG 使用之CBCGPTabWnd控件(相当于MFC TabControl)
- Jetpack Compose 教程
- Lm10 cosine wave homeopathic grid strategy
- Allure of pytest visual test report
- Matrix flip (array simulation)
- Add namespace declaration
猜你喜欢
LM10丨余弦波动顺势网格策略
Stream流
如何使用Async-Awati异步任务处理代替BackgroundWorker?
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
Lm10 cosine wave homeopathic grid strategy
92.(cesium篇)cesium楼栋分层
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
牛客小白月赛7 谁是神箭手
随机推荐
测试工程师如何“攻城”(上)
Niuke Xiaobai month race 7 who is the divine Archer
YOLOv5s-ShuffleNetV2
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
Hough Transform 霍夫变换原理
线上数据库迁移的几种方法
Educational Codeforces Round 22 E. Army Creation
node_ Exporter deployment
Shell 编程核心技术《二》
The 300th weekly match of leetcode (20220703)
Some thoughts on whether the judgment point is located in the contour
Educational codeforces round 22 E. Army Creation
Online data migration scheme encountered in the project 1 - general idea sorting and technical sorting
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
Stream流
1003 emergency (25 points) (PAT class a)
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
Is it safe to open an account at Great Wall Securities? How to open an account when buying stocks
1009 Product of Polynomials(25 分)(PAT甲级)