Introduction to JOINs
Real databases have multiple related tables. JOINs let you combine them to get complete information.
New Tables Available
Starting this module, you have access to order-related tables:
- orders - Customer orders (user_id, order_date, total, status)
- order_items - Items in each order (order_id, product_id, quantity, price_at_time)
These tables reference each other through ID columns (foreign keys).
Why JOIN?
Consider this: the orders table has user_id but not the user's name. The products table has product names but order_items only has product_id. JOINs let you combine these to answer questions like "What did Alice order?"
Basic JOIN Syntax
SELECT columns
FROM table1
JOIN table2 ON table1.column = table2.column;
The ON clause specifies how the tables relate.
Exercises
Table Aliases
Use short aliases to make JOINs more readable:
SELECT o.id, u.name
FROM orders o
JOIN users u ON o.user_id = u.id;
Free Practice
Try:
- Join products with categories to see category names
- Join order_items with orders to see order totals
- Experiment with different column selections
التالي · الدرس 19 من 27
INNER JOIN Practice
قراءة 1 دقيقة
أنهيت 18 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

