In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how mysql table connection, the text is very detailed, has a certain reference value, interested friends must read!
In the database, the select statement can not only query the information in the table, but also can be used to query the information of multiple tables, return the queried information, and learn together with Xiaobian.
Before we start this article, we will create two data tables (employee and employee_record). The employee data table stores the ID number, name, salary and department of the employee. Employee_record stores the employee's previous work experience. Here is the data in the table. Operations will be based on these two tables.
inner connection
Select data matching each other from multiple tables and output them.
Grammar:
(Select table. Fields,... from Table 1, Table 2,... where [matching conditions such as Table 1. field = Table 2. field];
Of which:
Table: refers to the data table that needs to be operated, such as employee and employee_record here;
Field: refers to the name of the field to be operated on.
If you don't want to read it, let's look at an example:
Select statements can alias fields! Write directly after the field that needs to be queried and displayed, or alias the table.
outer connection
External links not only select records that match each other in multiple tables, but also query other unmatched records.
left connection
Contains all records in the left table (including records that do not match it in the right table), the so-called left table is distinguished by the left join, the left table is on the left of the left join, and the right table is on the right.
Grammar:
select * from Table 1 left join Table 2 on Table 1. Field = Table 2. Field;
We can see that although there is no corresponding one on the right in the following lines, it is still displayed.
right connection
Contains all records in the right table (including records in the left table that do not match it). The grammar of right-linking is very similar to that of left-linking, except that individual words differ.
Grammar:
select * from Table 1 right join Table 2 on Table 1. Field = Table 2. Field;
You can see that the right link displays exactly the opposite of the left link.
Note: Left and right links are interchangeable.
The above is all the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.
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.