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

How to distinguish between left outer connection, right outer connection and full outer connection

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how to distinguish between left outer connection, right outer connection and full external connection. The article is very detailed and has certain reference value. Interested friends must read it!

The left outer join returns records that include all records in the left table and equal join fields in the right table; if there is no data in the right table, it is null. The right outer join returns records that include all records in the right table and the join fields in the left table are equal; if there is no data in the left table, it is null. The full outer join returns all records in the left and right table that are equal to the join fields in the left and right table.

In sql, l outer connection includes left connection (left join) and right connection (right join), and full outer connection (full join).

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

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

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.

Put two tables first, one for students and one for grades.

Left outer connection

All rows of the right table are returned. If a row of the left table does not match in the right table, a null value will be returned for the right table. Left join: select * from Student LEFT JOIN Score ON Student.s_id=Score.s_id

Take the left table as the main table, and the right table has no data as null.

Right outer connection

All rows of the right table are returned. If a row of the right table does not match in the left table, a null value will be returned for the left table

The right table is the main table, and the one with no data in the left table is null.

Select * from Student right JOIN Score ON Student.s_id=Score.s_id

Full external connection (FULL JOIN or FULL OUTER JOIN)

The full outer join returns all rows in the left and right tables. When a row does not match a row in another table, the select list column of the other table contains null values. If there are matching rows between tables, the entire result set row contains the data values of the base table.

Select * from Student full JOIN Score ON Student.s_id=Score.s_idselect * from Student full outer JOIN Score ON Student.s_id=Score.s_id

The above is all the contents of the article "how to distinguish between left outer connection, right outer connection and full outer connection". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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: 0

*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

Database

Wechat

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

12
Report