当前位置:网站首页>multi-table query
multi-table query
2022-07-27 12:42:00 【Rippling rippling】
Classification of multi table query
1. Internal connection
2. External connection
3. Cross connect ( understand )
notes : The GUI manager used is :Navicat Permium 12
Internal connection
Essence is : Intersection of multiple tables .
#user_info surface
create table user_info(
id int(2) primary key,
user_name varchar(12) unique,
password varchar(15) not null,
real_name varchar(8) not null,
age int(3)
);
#address surface
create table address(
id int(2) primary key,
user_id int(2) not null,
real_name varchar(8),
mobile char(11),
address varchar(150)
);
insert into user_info values(1,' Shallow singing of happiness ','[email protected]',' Wang Xiaoming ',12);
insert into address values(1,1,' Xiao Ming Wang ','15516472282',' Taiyuan, Shanxi ');
insert into address values(2,1,' Wang Xin ','18404905139',' Datong, Shanxi ');
insert into address values(3,1,' Ren Jian ','15333021730',' Shanxi Jincheng ');
insert into user_info values(2,'ぅ man 's life is like a dream 〤','56701wz',' Wang Nan ',36);
insert into address values(4,2,' Wang Nan ','15010303314',' Beijing haidian ');
insert into address values(5,2,' Zhao Jie ','18435224278',' Shanxi changzhi ');
insert into user_info values(3,' corner の Wind chime ','27w4921',' Li Xiaofei ',9);
insert into address values(6,6,' Liu Qian ','13159775555',' Changchun, Jilin ');
Explicit Equivalent connection :
Format :
select ui.*,addr.*
from address addr
join user_info ui on ui.id=addr.user_id;
Implicit Equivalent connection :
Format :
select ui.*,addr.* from user_info ui,address addr where ui.id=addr.user_id;
Although they have different formats , But the results are the same
result :
External connection
External connection classification :
1. Left outer link
2. Right outer link
3. Full outer join ( Because the total external connection is Oracle So here we just know )
The left outer join :
characteristic : With left Keywords are references , The table on the left of the keyword is the main table , Display all its data , Even if there is no data from the table
Format :
select ui.*,addr.*
from user_info ui
left join address addr on ui.id =addr.user_id;
result :
Right connection :
characteristic : With right Keywords are references , The table on the right of the keyword is the main table , Display all its data , Even if there is no data from the table
Format :
select ui.*,addr.*
from address addr
right join user_info ui on ui.id=addr.user_id;
result :
notes : The left outer connection and the right outer connection can be transformed into each other .
example :
The left outer join
select ui.*,addr.*
from address addr
left join user_info ui on ui.id =addr.user_id;
Right connection
select ui.*,addr.*
from user_info ui
right join address addr on ui.id=addr.user_id;
result :
边栏推荐
- Chain representation and implementation of queues
- (10) STM32 - systick tick timer
- Do you really understand CMS garbage collector?
- 「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
- What are metauniverse and NFT digital collections?
- ECCV2022 | RU&谷歌提出用CLIP进行zero-shot目标检测!
- 20210520 TCP sliding window
- 为什么需要外键?
- Xposed+fdex2 app shelling (black cat complains about app shelling)
- BSP视频教程第21期:轻松一键实现串口DMA不定长收发,支持裸机和RTOS,含MDK和IAR两种玩法,比STM32CubeMX还方便(2022-07-24)
猜你喜欢

2021-3-22-directed graph sorting

Self built personalized automatic quotation system to cope with changeable quotation mode

Detail try catch finally

Security measures for tcp/ip protocol vulnerabilities

Distributed system architecture theory and components

Set interface

Map interface

How to use the server to build our blog

Finally, I was ranked first in the content ranking in the professional field. I haven't been tired in vain during this period. Thanks to CSDN's official platform, I'm lucky and bitter.

XXL job parameter transfer
随机推荐
Top 10 international NFT exchanges
分布式系统架构理论与组件
What should I do if I can't see any tiles on SAP Fiori launchpad?
Map接口
Mixin\ plug in \scoped style
MySQL common commands
BSP视频教程第21期:轻松一键实现串口DMA不定长收发,支持裸机和RTOS,含MDK和IAR两种玩法,比STM32CubeMX还方便(2022-07-24)
How to use the server to build our blog
Do you really understand CMS garbage collector?
(07) flask is OK if you have a hand -- flask Sqlalchemy
Interviewer: how to deal with the data loss of redis master-slave cluster switching?
About typora's inability to log in after March 9, 2022 -- resolved
Log4j2.xml configuration details
Why does MySQL index use b+ tree instead of jump table?
【萌新解题】斐波那契数列
Common usage of curl command
2022 global Vocational Education Industry Development Report
20210512 recursive formula
flinksql从Oracle同步数据到Doris,一共50几个字段,Oracle表中3000多万条
【表达式计算】双栈 : 表达式计算问题的通用解法