Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of left connection, right connection, inner connection and full connection in Mysql

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the use of left connection, right connection, inner connection and full connection in Mysql. The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the usage of left connection, right connection, inner connection and full connection in Mysql.

1. Basic definition

Left join (left join): returns records that include all records in the left table and records with equal join fields in the right table.

Right join (right join): returns records that include all records in the right table and records that are equal to the join fields in the left table.

Inner join (equivalent join or inner join): only rows with equal join fields in two tables are returned.

Full join (full external join): returns all records in the left and right table that are equal to the join fields in the left and right table.

Take a chestnut:

Form A, form B

IdnameidA_ idjob1 Xiao Wang 12 teachers 2 Xiao Li 24 programmers 3 Xiao Liu

Inner join: only rows that match between two tables can be displayed

Select a.name,b.job from An an innner join B b on a.id=b.A_id

Result: Mr. Xiao Li

Left join: the table on the left is unrestricted

Select a.name, b.job from An a left join B b on a.id=b.A_id

Result: Xiao Wang null

Miss Xiao Li

Xiao Liu null

Right join: the table on the right is unrestricted

Select a.name, b.job from An a right join B b on a.id=b.A_ia

Result: Mr. Xiao Li

Null programmer

Full connection: there are no restrictions on the left and right tables

Select a.name, b.job from An a full join B b on a.id=b.A_id

Result: Xiao Wang null

Miss Xiao Li

Xiao Liu null

Null programmer

Note: external and external connections in sql include: left connection, right connection, full connection.

Equivalent connection is also called inner connection.

Thank you for your reading, the above is the content of "left connection, right connection, inner connection and full connection in Mysql". After the study of this article, I believe you have a deeper understanding of the usage of left connection, right connection, inner connection and full connection in Mysql, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 298

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report