Site icon Businesss Hed

How the SQL query with two left join works?

I need help in understanding how left join is working in below query.

There are total three tables and two left joins.

So my question is, the second left join is between customer and books table or between result of first join and books table?

SELECT c.id, c.first_name, c.last_name, s.date AS sale,
 b.name AS book, b.genre
FROM customers c
LEFT JOIN sales s
ON c.id = s.customer_id
LEFT JOIN books b
ON s.book_id = b.id;
Exit mobile version