Easy Way To Remember SQL Joins - A visual explanation


In reality, SQL joins are easy to understand. But people usually seem to get confused between them. In this article, you can find a well known way to remember and understand visual explanation on how SQL joins relate to their corresponding names. Along with the visual representation, we had provide a sample query for each type of Join.

Left Join
Left Join
Select [ fields ] from A left join B on A.key = B.key

As shown in the above figure, when we left join Table A and B, related items of the Table A which resides in Table B will be shown in the result and rest of Table B will be left out.

Right Join
right Join
Select [ fields ] from A right join B on A.key = B.key

When we right join Table B and A, matching keys of Table B in the Table A will be shown in the result.

Inner Join

inner Join
Select [ fields ] from A inner join B on A.key = B.key

Left Join With NULL

Left Join with NULL
Select [ fields ] from A left join B on A.key = B.key where A.key is null

Right Join With NULL

right join with NULL
Select [ fields ] from A left join B on A.key = B.key where B.key is null

Full Join

Full Join
Select [ fields ] from A full outer join B on A.key = B.key

Full Join With NULL

Full Join Null
Select [ fields ] from A full outer join B on A.key = B.key where A.key is null or B.key is null
Planning to do an MBA?
A quick all-in-one MBA entry manual for MBA Aspirants. Book covers
  • Possible MBA Tests & Exam Preparation
  • Tips to choose right program
  • Essay, Resume & Letter of Recommendation
  • MBA Interview Preparation
  • MBA Financial Planning
Price - 6.99$
 

Popular Videos

How to speak to people

How to speak so that people want to listen.

Got a tip or Question?
Let us know

Related Articles

Overriding JAXB binding at client side
Setting Expires header in .htaccess to improve your page load time
J2EE User Authentication using servlet filters
Login Using Facebook Account - FB Connect
Step By Step Tutorial On LDAP Using Java JNDI
Zoning and LUN Masking