当前位置:网站首页>多表操作-外连接查询
多表操作-外连接查询
2022-07-04 18:32:00 【汤键.TJ】
目录
- 外连接查询分为左外连接查询和右外连接查询
- 以某张表为主,取出里面的所有记录,然后每条与另外一张表进行连接,不管能不能匹配上条件,最终都会保留
- 能匹配,正确保留;不能匹配,其它表的字段都置空(null),称为外连接
左外连接
- 查询原理
- 查询左表的全部数据,和左右两张表有交集部分的数据
- 查询语法
- select 列名 from 表名1 left [outer] join 表名2 on 条件
右外连接
- 查询原理
- 查询右表的全部数据,和左右两张表有交集部分的数据
- 查询语法
- select 列名 from 表名1 right [outer] join 表名2 on 条件
实例操作
- 表的数据准备请点击查看
- 左外连接
- 查询所有用户信息,以及用户对应的订单信息

-- 左外连接 -- 查询所有用户信息,以及用户对应的订单信息 SELECT u.*, o.number FROM user u LEFT OUTER JOIN orderlist o ON o.uid=u.id;- 右外连接
- 查询所有订单信息,以及订单所属的用户信息

-- 右外连接 -- 查询所有订单信息,以及订单所属的用户信息 SELECT o.*, u.name FROM user u RIGHT OUTER JOIN orderlist o ON o.uid=u.id;
边栏推荐
- node_exporter部署
- Reflection (I)
- Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
- Shell programming core technology "four"
- Shell programming core technology II
- 1011 World Cup Betting (20 分)(PAT甲级)
- Hough transform Hough transform principle
- 矩阵翻转(数组模拟)
- Pytest 可视化测试报告之 Allure
- Mysql database basic operation -ddl | dark horse programmer
猜你喜欢

There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks

黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,
Some thoughts on whether the judgment point is located in the contour

联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点

To sort out messy header files, I use include what you use

MySQL数据库基本操作-DDL | 黑马程序员

勾股数规律(任意三个数能够满足勾股定理需要满足的条件)

The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize

FPGA时序约束分享01_四大步骤简述

BCG 使用之CBCGPTabWnd控件(相当于MFC TabControl)
随机推荐
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
Stream stream
Add namespace declaration
BCG 使用之CBCGPProgressDlgCtrl進度條使用
如何使用Async-Awati异步任務處理代替BackgroundWorker?
MySQL数据库基本操作-DDL | 黑马程序员
Matrix flip (array simulation)
如何使用Async-Awati异步任务处理代替BackgroundWorker?
HDU 6440 2018 Chinese college student program design network competition
Hough transform Hough transform principle
Shell 编程核心技术《二》
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
西门子HMI下载时提示缺少面板映像解决方案
Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
QT realizes interface sliding switching effect
Wechat reading notes of "work, consumerism and the new poor"
2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions
2021 Hefei informatics competition primary school group
Introduction to polyfit software
明明的随机数

