Middle+
How does a LEFT JOIN work?
sobes.tech AI
Answer from AI
LEFT JOIN is a type of table join in SQL that returns all records from the left table and the matching records from the right table. If there are no matches in the right table, the result set will contain NULL values for those rows.
Example:
SELECT a.id, a.name, b.order_date
FROM customers a
LEFT JOIN orders b ON a.id = b.customer_id;
This will display all customers, even if they have no orders. For customers without orders, the order_date field will be NULL.