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)05/31 Report--
This article mainly introduces "what is the difference between left join and right join in the database". In the daily operation, I believe that many people have doubts about the difference between left join and right join in the database. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what is the difference between left join and right join in the database?" Next, please follow the editor to study!
Related to Left Join / Right Join / inner join
A sentence about the summation of left and right connections:
The left connection where only shadows the right table, and the right connection where only affects the left table.
Left Join
Select * from tbl1 Left Join tbl2 where tbl1.ID = tbl2.ID
The result of the search after the left connection is to display all the data in tbl1 and the data in tbl2 that meet the where condition.
In short, Left Join affects the table on the right.
Right Join
Select * from tbl1 Right Join tbl2 where tbl1.ID = tbl2.ID
The result of the search is all the data in tbl2 and the data in tbl1 that meet the where condition.
In short, Right Join affects the table on the left.
Inner join
Select * FROM tbl1 INNER JOIN tbl2 ON tbl1.ID = tbl2.ID
The function is the same as select * from tbl1,tbl2 where tbl1.id=tbl2.id.
Other relevant materials
1. The join statement used in the where clause is called an implicit connection in the database language. INNER JOIN... The connection produced by the ON clause is called an explicit join. (other JOIN parameters are also explicit joins) there is no essential difference in the connection relationship between WHERE and INNER JOIN, and the result is the same. But! With the standardization and development of database language, implicit connection has been gradually eliminated, and the relatively new database language has basically abandoned implicit connection and adopted explicit connection.
2. No matter how you join, you can use the join clause, but when joining the same table, be careful to define an alias, otherwise an error will occur!
A > inner join: understood as "valid connection", only some data in both tables will display left join: if it is understood as "there is a left display", such as on a.field=b.field, it will show all the data in table an and the data in a\ b, and the data in An and B will be displayed in null.
B > right join: understood as "with right display", such as on a.field=b.field, all the data in table B and data in a\\ b are displayed, and the data that are in B and not in An are displayed in null.
C > full join: understood as "full connection". All the data in the two tables shows that it is actually inner + (left-inner) + (right-inner).
3. Join can be divided into three types of out-of-table joins: complete outreach, left-sided join and right-hand join.
Full outreach contains all the records of the two tables.
The left couplet is dominated by the left table, the right couplet is secondary, and the right couplet is the opposite.
4. Generally speaking, the following principles should be followed to improve the performance of database query statements:
When doing a table-to-table join query, the big table is in front and the small table is in the
Do not use table aliases and distinguish fields in different tables by field prefixes
The constraints in the query conditions should be written before the table join conditions.
Try to use the fields of the index as query conditions
At this point, the study on "what is the difference between left join and right join in the database" 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.
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.