- MySQL 8 for Big Data
- Shabbir Challawala Jaydip Lakhatariya Chintan Mehta Kandarp Patel
- 78字
- 2021-08-20 10:06:14
LEFT JOIN
LEFT JOIN retrieves all the records from the left table while only matching records from the right table. If we use the customer and order table example with left join, it will fetch all records from the order table even if there are no matches in the right table (customer). To fetch all order details for the customer, the following query can be used:
SELECT order.order_id, customer.name
FROM order
LEFT JOIN customer ON order.customer_id = customer.customer_id;