Home > Database > SQL > body text

Is join on in sql an inner join?

下次还敢
Release: 2024-05-08 09:21:18
Original
817 people have browsed it

Yes, JOIN ON is a type of inner connection in SQL. It only returns rows with matching rows in the two tables. The comparison condition determines which rows match.

Is join on in sql an inner join?

Is JOIN ON an inner join in SQL?

Answer: Yes, JOIN ON is a type of inner join in SQL.

Detailed explanation:

Inner join is a join operation that only returns rows with matching rows in the two tables. When using JOIN ON, the comparison conditions in the WHERE clause determine which rows will match.

The following is the syntax for an inner join:

<code>SELECT *
FROM 表1
JOIN 表2 ON 表1.列名 = 表2.列名</code>
Copy after login

In this syntax:

  • SELECT * Returns the values ​​of all columns in the two tables .
  • FROM table 1 and FROM table 2 specify the tables to be joined.
  • ON Table 1. Column Name = Table 2. Column Name is the comparison condition, which specifies the basis for joining the two tables.

When using JOIN ON, only rows from records with matching values ​​in the two tables will be returned. This is different from outer joins, which also return unmatched records.

Example:

Suppose we have two tables:

Table 1: Customer

Customer ID Customer Name
1 John Doe
2 Jane Smith

Table 2: Order

Order ID Customer ID Order Date
1 1 2023-01-01
2 2 2023-01-02

Using JOIN ON, we can join these two tables to return customers that exist in both the customers table and the orders table:

<code>SELECT *
FROM 客户
JOIN 订单 ON 客户.客户 ID = 订单.客户 ID</code>
Copy after login

The result will look like this:

Customer ID Customer Name Order ID Order Date
1 John Doe 1 2023-01-01
2 Jane Smith 2 2023-01-02

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

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template