In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly discusses the difference between left link and right link in MySQL. There is a certain reference value, friends in need can refer to, follow the editor to see the solution.
First, create two new tables with the following data:
Student data:
Score data:
You can see that the record with stu_id 16048008 in the students table has no data corresponding to the score table.
1. When making an internal join, the system automatically ignores the data that does not match in the two tables:
-- all data connected in the display: SELECT * FROM students st INNER JOIN score sc ON st.sid=sc.stu_id
There is too much data, only the one at the end of the screenshot:
As you can see, the data only displayed to 16048007 16048008 is not displayed, so the inner connection only displays all related data.
two。 The left link shows all the data in the table on the left side of the keyword left. The data in the table on the right side is missing null values, and will not be displayed if there is more data.
-- left outer link leftSELECT * FROM students st LEFT JOIN score sc ON st.sid=sc.stu_id
As you can see, 16048008 has no data in the score table on the right, and the system completes it with NUll
SELECT * FROM score sc LEFT JOIN students st ON st.sid=sc.stu_id
The above picture shows the running result of changing the location of the students table and the score table. We can see that the original right table 16048008 records, because there is no data corresponding to the left table clock, so it is deleted. It can be seen that the left link takes the data in the left table as a reference to show all the data in the left table, while the right table only shows the data corresponding to the left table, with less complement NULl and more deletion.
By the same token, the right link takes the right as a reference, the left side has less complement NULL, and more deletions, so I won't say much here.
The above can be concluded as follows:
1. Internal join, showing all the linked data in the two tables
two。 The left link, with the left table as a reference, displays all data
3. Right link to display data with reference to the right table
After reading the above, do you have a general understanding of the difference between left and right links in MySQL? If you want to know more about the content of the article, welcome to follow the industry information channel, thank you for reading!
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.