Home >Daily Programming >Mysql Knowledge >What is the usage of inner join?

What is the usage of inner join?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-22 10:16:0941838browse

What is the usage of inner join?

inner join (equi-join): Only return rows with equal join fields in the two tables.

left join (left join): Returns all records in the left table that are equal to the join fields in the right table.

right join (right join): Returns all records in the right table that are equal to the join fields in the left table.

Related recommendations: "mysql database knowledge learning"

INNER JOIN syntax:

INNER JOIN connects two data tables Usage:

SELECT * FROM 表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号

INNER JOIN Usage to connect three data tables:

SELECT * FROM (表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号

INNER JOIN Usage to connect four data tables:

SELECT * FROM ((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号) 
INNER JOIN 表4 ON Member.字段号=表4.字段号

INNER JOIN to connect five data Usage of tables:

SELECT * FROM (((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号) 
INNER JOIN 表4 ON Member.字段号=表4.字段号) INNER JOIN 表5 ON Member.字段号=表5.字段号

Usage of connecting six data tables: Omitted, similar to the above connection method, let’s draw inferences

Notes:

When entering letters, be sure to use English half-width punctuation marks and leave half-width spaces between words;

When creating a data table, if one table is connected to multiple tables, then the The field must be of the "Number" data type, and the same field in multiple tables must be a primary key and be of the "AutoNumber" data type. Otherwise, it will be difficult to connect successfully.

Quick method for code nesting: For example, if you want to connect five tables, you only need to add a front and back bracket to the code that connects four tables (the front bracket is added after FROM, and the back bracket is added at the end of the code That's it), and then continue to add the code "INNER JOIN table name X ON table 1. field number = table )

The above is the detailed content of What is the usage of inner join?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more