-------------------------------------------------------------------- The connection in the inner join condition indicates that only rows meeting the connection condition are displayed in both tables.
Example 1:Suppose there are two EXCEL reports: the shipment table and the product table shipment table: Date customer product code quantity 2003-10-20 Yonghua company 1001 102003-10-21 style company 1002 20 product table: product Code Product Name manufacturer 1001 PC chuangcheng company 1002 printer FengHua company connection conditions: Shipping table. product Code = product table. product Code connection result set: Date customer product number quantity product name manufacturer 1001-10-20 Yonghua company 1002 10 PC company-10-21 style company 20 printer wind Hua Company
Example 2:Book table
| Bookid |
Bookname |
Studentid |
| 1 |
Training |
3 |
| 2 |
Secrets of success |
5 |
| 3 |
Dream of Red Mansions |
3 |
| 4 |
West Chamber |
2 |
| 5 |
Water Margin |
6 |
| 6 |
Romance of the Three Kingdoms |
10 |
Student table
| Studentid |
Studentname |
| 1 |
Zhang San |
| 2 |
Li Si |
| 3 |
Guan Yu |
| 4 |
Zhang Fei |
| 5 |
Huang Cong |
| 6 |
Li Yun |
| 7 |
Zhao na |
| 8 |
Wang Min |
| Null |
Null |
Internal Connection query:
Select * from [Book] as B, [Student] As s where B. studentid = S. studentid
It is equivalent to the following (or you can leave the keyword inner, which is the default value)
Select * from [Book] as B inner join [Student] As S on B. studentid = S. studentid
Internal Connection query results:
| Bookid |
Bookname |
Studentid |
Studentname |
| 4 |
West Chamber |
2 |
Li Si |
| 1 |
Training |
3 |
Guan Yu |
| 3 |
Dream of Red Mansions |
3 |
Guan Yu |
| 2 |
Secrets of success |
5 |
Huang Cong |
External Connection ------------------------------------------------------------------------- query the left external connection:
Select * from [Book] as B left join [Student] As S on B. studentid = S. studentid
Query results:
| Bookid |
Bookname |
Studentid |
Studentid |
Studentname |
| 1 |
Training |
3 |
3 |
Guan Yu |
| 2 |
Secrets of success |
5 |
5 |
Huang Cong |
| 3 |
Dream of Red Mansions |
3 |
3 |
Guan Yu |
| 4 |
West Chamber |
2 |
2 |
Li Si |
| 5 |
Water Margin |
6 |
6 |
Li Yun |
| 6 |
Romance of the Three Kingdoms |
10 |
Null |
Null |
Execution Process:
That is, use the book table from [Book] Left join [Student] as the benchmark, that is, the B. studentid of the book table (table B) as the benchmark. Traverse the B. studentid matched in the student table (s table. If B. studentid contains S. studentid matching items, splice them and traverse the next S. studentid in the student table. After the query is completed, enter the next B. studentid. If B. studentid does not match S. studentid, items in the left table are displayed, and items in the right table are displayed as null.