Skip to content

INNER JOIN · ⁨内连接 INNER JOIN⁩

English

Joining two tables

To use data from both tables at once, you join them. An INNER JOIN pairs up rows that match on a key — here, the order's customer_id with the customer's id:

When a column name could come from either table, write table.column so it is clear.

中文

连接两张表

要同时使用两张表的数据,就把它们连接起来。INNER JOIN 把在某个键上匹配的行配成一对 —— 这里是订单的 customer_id 和顾客的 id:

SELECT customer.name, orders.total
FROM customer
INNER JOIN orders ON customer.id = orders.customer_id;

当一个列名两张表都可能有时,写成 table.column,这样更清楚。

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩