search
HomeDaily ProgrammingMysql KnowledgeWhat is the usage of inner join?

What is the usage of inner join?

Jul 22, 2019 am 10:16 AM
inner joinmysqlusage

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.