What is the usage of inner join?

爱喝马黛茶的安东尼
Release: 2019-07-22 10:16:09
Original
41754 people have browsed it

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.字段号
Copy after login

INNER JOIN Usage to connect three data tables:

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

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.字段号
Copy after login

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.字段号
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template