All About SQL Joins
I was recently asked in an interview to explain the difference between a JOIN
and a LEFT JOIN
in SQL. Admittedly it had been a while since I had thought about the different SQL joins and I fumbled a little with my answer. So I am taking this opportunity to dive into SQL joins.
What is a SQL join?
A SQL join is a way to combine rows from two or more tables based on a common column between them.
- Let’s break that down using a book and author example where authors can have many books, and a book belongs to an author.
The authors
table has an id
primary key, name
, and age
: