Skip to content · ⁨Passer au contenu⁩
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.

Français

Joindre deux tables

Pour utiliser des données provenant de les deux tables en même temps, vous devez les joindre. Un INNER JOIN associe les lignes qui correspondent sur une clé — ici, la customer_id de la commande avec la id du client :

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

Lorsqu'un nom de colonne pourrait provenir de l'une ou l'autre table, écrivez table.column pour clarifier.

Handout · ⁨Fiche de cours⁩

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP