Skip to content · ⁨דלג לתוכן⁩
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 & AP