In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following is followed by the author to understand the difference between mysql and left join, right join and inner join. I believe you will benefit a lot after reading it. The text is not much in essence. I hope that mysql connects left join, right join and inner join. What is the difference between this short article? you want.
A gas card meter:
Id, userName, cardNo
1 aaa 111
2 bbb 111
3 aaa 222
B refueling record sheet:
Id, number, userName, cardNo
1 1234 aaa 111
2 234 bbb 111
Left join:
Select * from B b left join An an on a.userName = b.userName where b.userName=aaa
Because of the condition after on in sql above, userName corresponds to more than one item in A table, and the result set is Cartesian product. One item in table B satisfies the two items in the remaining table A. The results were 2.
Select * from B b left join An an on a.userName = b.userName and a.cardNo = b.cardNo where b.userName=aaa
Because in the above sql, only one unique piece of data can be found in table A under the two conditions followed by on, so the result is that the result set returns as many pieces of data in table B satisfy where. Here is to return a piece of data
Right join:
The following sql has the same effect as the left join above:
Select * from An a right join B b on a.userName = b.userName and a.cardNo = b.cardNo where b.userName=aaa
Inner join:
Select * from An an inner join B b on a.username = b.userName and a.cardNo = b.cardNo where a.userName=aaa
First of all, let's look at the conditions after on. If a piece of data in table A corresponds to two conditions of on and there is only one piece of data in B, two pieces of data that meet the where condition are returned.
Select * from B b inner join An an on a.username = b.userName and a.cardNo = b.cardNo where a.userName=aaa
After reading this article about the difference between mysql and left join, right join and inner join, many readers will definitely want to know more about it. For more industry information, you can follow our industry information section.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.