当前位置:网站首页>MySQL join and index
MySQL join and index
2022-07-22 17:40:00 【Yan Ran】
Catalog
3、 ... and 、left join and right join
Four 、MySQL Workbench Graphic software
One 、join
join have Connect effect . When two or more tables are related , You can use jion To connect these related tables to process or analyze data .
join The relevant connection mechanism of is as follows :
Will find jion The column name after is the result of adding the two tables ( The same may happen , As in the above example ).S1 jion S2 after ,S1 The columns in will be associated with S2 The columns in are merged one by one to form a new table . So in the above example, the last generated new table is 3 * 2 = 6 Columns .
If you are not satisfied with the newly generated table at this time , Want the corresponding options together , We can choose to use it on.
Two 、on
on be used for Adding constraints . For example, in use S1 join S2 When merging tables , We want to make S1 Medium l1 Column and S2 Medium l2 When the columns match equally , We can change the sentence to :S1 join S2 on S1.l1 = S2.l2
On the premise that the column names are not repeated , We can also directly do without . The operator .
Or the example above :
You can see that the merger is no longer the same as before “ The fool ” Amalgamated , It's going to be classid and id A new table formed by merging equal columns into one .
3、 ... and 、left join and right join
The two statements are of the same nature , and join comparison ,left / right join The main difference is left / right join There must be on.
left join
left join Statement will check whether the data of the left table is included in the new table , If you lack it, use NULL Fill in :
One thing to note : about left join The position of the left and right watches is very important . stay join You can exchange positions in , The resulting new tables are the same ; But use left join Words , Exchange the positions of the left and right tables, and the resulting new table is completely different . So let's take this example , If you will stu and class The exchange of positions :
So when writing, you must pay attention to .
right join
and left join The same property is opposite :
A right join B= B left join A --> It's all about B Benchmarking
Four 、MySQL Workbench Graphic software
Found by accident , After downloading, connect to your own library and find it very convenient , You can create and manage your database in it . Mainly can be graphical , Macros are easy to watch when designing . But in the final analysis, it is better to use more terminal operations , This can be an auxiliary .
MySQL Workbench Use the tutorial - How to use Workbench operation MySQL / MariaDB Database Chinese guide - Karayun Speaking of terminal operation , Today, I also installed a plug-in that can automatically complete sql sentence , It's so convenient ( Roar , Yesterday, I was still working for SQL The sentence is always wrong and annoyed .
It's called mycli, After installation, you can directly open the relevant library from the command line :
It can also mark the names of commands and tables in green , It looks much more comfortable , I love it .

边栏推荐
- Openeuler is ambitious, open source huizhichuang future | 2022 open atom global open source summit openeuler sub forum is about to open
- DOM operation of JS -- prevent event bubbling and block default events
- Discussion on the path of Chinese enterprise management software towards globalization and internationalization
- How can Tiktok cancel his account? What are the steps of the operation process?
- Overview of nftfi track layout
- STL resize capacity rule set
- 【计网】(三)超网、路由、NAT协议
- Comparison between symmetric encryption and asymmetric encryption
- [learning notes, dog learning C] deeply understand arrays and pointers
- Understand five popular NFT delivery methods and their advantages and disadvantages
猜你喜欢
Ajout, suppression et modification de MySQL (niveau avancé)
会议OA项目之项目简介&会议发布
生产线平衡优化毕业论文【flexsim仿真】
备战攻防演练,这里有一张腾讯安全重保布防图!
[external sorting] merge ideas to complete external sorting
NFS Shared Storage Service
Detailed explanation of inheritance
Can the values of multiple fields be judged at the same time in MySQL query
MySQL 增删改查(進階)
[matrix multiplication] external matrix multiplication
随机推荐
VR全景在各行各业是如何展示?如何落地应用的?
MySQL JDBC programming
【开发者必看】【push kit】推送服务服务典型问题合集1
【FPGA教程案例35】通信案例5——基于FPGA的16QAM调制信号产生,通过matlab测试其星座图
What is the difference between win11 beta 22621.436 and 22622.436?
How much do you know about the basic features of SolidWorks| Four methods of extruding features
How does win11 run as an administrator? Win11 setup method running as Administrator
Understand five popular NFT delivery methods and their advantages and disadvantages
Family Trivia
How can Tiktok cancel his account? What are the steps of the operation process?
Openeuler is ambitious, open source huizhichuang future | 2022 open atom global open source summit openeuler sub forum is about to open
Prepare for the attack and defense drill. Here is a security deployment map of Tencent!
关键路径问题
Detailed explanation of inheritance
SSRF vulnerability attack intranet redis recurrence
会议OA项目之项目简介&会议发布
"New capabilities" of rongyun Super Group
OSPF special area comprehensive experiment
Misc advanced
132. Split palindrome string II