JOIN ON is a syntax for joining tables in SQL. It combines rows in different tables based on common columns and is used to: 1. Combine related table data; 2. Retrieve cross-table information; 3. Update or delete cross-table data.
The meaning of JOIN ON in SQL
JOIN ON is a way to join two or more tables in a SQL query A grammatical structure. It allows us to group rows from different tables together based on common columns.
Syntax
<code class="sql">SELECT column_list FROM table1 JOIN table2 ON table1.column_name = table2.column_name;</code>
Where:
column_list
Specifies the columns to be retrieved from the query. table1
and table2
are the tables to be joined. column_name
is the matching column name in the two tables. Function
JOIN ON is used to match rows from two tables together based on specified conditions. When the join condition is met, it creates a row containing the corresponding data from both tables.
JOIN ON is usually used to:
Example
The following query uses customers
table and orders
table using customer_id
Columns concatenated:
<code class="sql">SELECT * FROM customers JOIN orders ON customers.customer_id = orders.customer_id;</code>
This will return a table with information for each customer and all of their orders.
The above is the detailed content of What does join on mean in sql. For more information, please follow other related articles on the PHP Chinese website!