Introduction to Joins

Introduction to Joins

Table of contents

Hello again. Quick question, if you're into SQL, are you the no case type of person, or all case type of person? Do let me know in the comments section.

Updates

I am halfway through the second course under the SQL track on DataCamp!! I am so excited really. It's been a great journey so far and as usual, I'm here to share insights with you.

Joins are easy... so I was told. Turns out, they actually are. This week, it's been all about joins in the course and understanding it was initially difficult. In case you haven't heard about joins before, firstly, you need to make sure you know about SQL and the basics before moving to joins. I wrote an article on the basics of SQL and you can check this out here

What are Joins

Joins are used to join 2 or more tables together. Let's take a practical example. Say you have 2 Tables, one for the names of students and their ID and the other containing their ID and Economics test scores as shown in the picture below.

Untitled (1).png

From the picture, you can immediately tell who has the highest score but they are in separate tables. As a Data Analyst or teacher in this case, if your aim is to analyze the student performance rate, you need both tables to become one. This is when your knowledge of joins comes to play.

This scenario is fairly simple and you can use 'inner join' to achieve your desired result. Inner Join means you are telling SQL you add columns from a different table. To join two tables, they both have to have at least one attribute (column) in common. In this case, you might have guessed already, that the common attribute is ID. So here's what you tell SQL because remember, SQL is a language. You are speaking to a tool (okay this maybe sounds weird) but it's a way of communicating. If you begin to see it this way right from the start, it could really help you during your learning journey.

2022-08-30 (1).png You have just told SQL to join 2 tables, and match them on their shared attribute; ID. It might seem complicated at first but after a while, you will understand the language better and get SQL to carry out these tasks. This is how the result will look:

Slide 16_9 - 1.png Of course, this isn't all there is to Joins. Like I said earlier there are a lot more complicated scenarios but this may help you understand a few things during your journey.

I hope to see you next time!