Understanding SQL Joins Using Pictures

Finally found a valid explanation on how ‘join’ works in SQL. What is the difference between an inner join and left, or right join?

The most common of which is inner join that works internally without using it. Few times you get to use outer joins but mostly the SQL statements contain inner joins.

An inner join can also be represented by the diagram as the intersection of two sets, ie, a result of query with inner join shows records from tables matching fields in the union.

Graphical view of all the SQL joins - Understanding SQL Joins Using Pictures

Suppose we have a table with employees of a company and have other departments (Id and Name) . Some workers have assigned department and others not, and obviously the relationship between the two tables is given between the Department Id with ID field in the Employees table. Using an inner join we could get a list of all employees who have an assigned department:

This is a very simple query but it goes complex with adding several tables and adding complex conditions in a WHERE clause.

I have compiled some websites that explain the joins so beautifully and easily. After reading, you even don’t have to remember it.

Scroll to Top