Home >Database >Mysql Tutorial >What does inner join mean?

What does inner join mean?

王林
王林Original
2020-06-28 13:34:0635409browse

The inner join clause is used to match rows in one table with rows in other tables and allows querying row records containing columns from both tables. The specific usage is as follows: [select column_list from t1 inner join t2 on join_condition].

What does inner join mean?

inner join (equivalent join)

(recommended tutorial: mysql tutorial)

The INNER JOIN clause is used to match rows in one table with rows in other tables, and allows row records containing columns to be queried from two tables, returning rows with equal join fields in the two tables.

Before using the INNER JOIN clause, the following conditions must be specified:

First, specify the main table in the FROM clause;

Secondly, the table must The main table to be joined should appear in the INNER JOIN clause. In theory, it is possible to join multiple other tables. However, for better performance, you should limit the number of tables to be joined (preferably no more than three tables);

Finally, join conditions or join predicates. The join condition appears after the ON keyword of the INNER JOIN clause. Join conditions are rules that match rows in the main table with rows in other tables.

Example:

Assume that the INNER JOIN clause is used to connect two tables: t1 and t2. The syntax is as follows:

SELECT column_list
FROM t1
INNER JOIN t2 
ON join_condition;

For each row in the t1 table, the INNER JOIN clause The sentence compares it with each row of the t2 table to check whether they all meet the join conditions. When the join conditions are met, INNER JOIN will return new rows consisting of columns from the t1 and t2 tables.

Please note that the rows in the t1 and t2 tables must match based on the join conditions. If no match is found, the query returns an empty result set. This logic is also applied when joining more than 2 tables.

The above is the detailed content of What does inner join mean?. 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
Previous article:What does union all mean?Next article:What does union all mean?