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 skills of using sql left connection and right connection

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "sql left connection and right connection use skills". In daily operation, I believe that many people have doubts about the use skills of sql left and right links. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "sql left connection and right connection use skills". Next, please follow the editor to study!

Here is an example to illustrate:

Example

Table a

Aid adate

1 a1

2 a2

3 a3

Table b

Bid bdate

1 b1

2 b2

4 b4

Left join:

Select * from a left join b on a.aid = b.bid

First, take out all the data in table a, and then add the data that matches aformab.

What is taken out at this time is:

1 a1 b1

2 a2 b2

3 A3 null character

There is also right join.

It means to take out all the data in table b first, and then add the data that matches aforme b

What is taken out at this time is:

1 a1 b1

2 a2 b2

4 null character b4

Hehe, please note that the left and right connection is connected with the two tables aperior b. It is not the same to take out the same field data of id.

Select * from a, b where a.aid = b.bid this is only the matching data taken out.

What is taken out at this time is:

1 a1 b1

2 a2 b2

By the way, union and union all

Union is the data that joins two tables and excludes all duplicate data.

Union all does not rule out duplicate data.

At this point, the study of "skills for the use of sql left and right connections" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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