🔥 Master PostgreSQL INNER JOIN from scratch — beginner to advanced in one video!
In this tutorial, you'll learn: ✅ What is INNER JOIN and how it works using a Venn Diagram ✅ The proper definition and keywords you MUST know ✅ Exact syntax with breakdown ✅ Real-world examples with practical queries ✅ Best practices, tips & tricks to write clean JOIN queries ✅ 3 Hands-on queries — including one advanced challenge!
Whether you're a student, backend developer, or data analyst, understanding JOINs is the #1 skill in SQL. This video makes it simple.
━━━━━━━━━━━━━━━ ⏱️ TIMESTAMPS ⏱️ ━━━━━━━━━━━━━━━ 0:00 – Introduction to INNER JOIN in PostgreSQL 0:15 – INNER JOIN explained using Venn Diagram 1:40 – What is INNER JOIN? (Proper Definition) 2:00 – Important Keywords in JOIN 4:20 – INNER JOIN Syntax Breakdown 4:40 – Real World Example 5:10 – Best Practices, Tips & Tricks 6:35 – Query 1 – Practical (Beginner) 12:10 – Query 2 – Practical (Intermediate) 15:10 – Query 3 – Advanced JOIN Challenge
AI Generated·May contain errors
Video Summary
AI Generated
This tutorial provides a comprehensive guide to Inner Joins in PostgreSQL, explaining how to combine data from multiple tables using common columns. It covers fundamental concepts via Venn diagrams, SQL syntax, the resolution of ambiguous columns through aliases, and the practical implementation of joining three or more tables to retrieve complex, related datasets.
Hello, what's up, guys?
Welcome everyone to the Postgres SQL Series
And today in this video, we are going to take a look
Inner Joins
There are different variants of joins.
in which today we will cover Inner Joins
and you can see it
I already have a handwritten kind of image
I've kept it ready for you all
So that it becomes completely easy for you to understand
We all learned Venn diagrams in 10th grade.
I think it was in the 10th or 11th grade.
Hi there
You can see it very clearly here
We have one.
Imagine this as a table, just like a table.
This is your table number A.
and this is your table name B
So we have a total of 2 tables.
And yes, you have some values.
These are your values inside Table A.
These are your values inside Table B.
sets basically here
And in Dono Me, what common values do we have?
Simple question
Which of these values are such ones?
I mean, what's common
I can easily tell just by looking.
like in this case
Obviously, you can see it right here.
Yeah, 2, and then yeah, 4 is it.
Yeah, 2 and the 4
That's common.
Hi there
And yes, what's there isn't common.
Yes, these two things
What am I supposed to say here?
Yes, these two sets are there
These two tables here
In the middle of the ink, what is the value of the one that is 2 and the one that is 4
They are common.
It's common.
so A intersection B
if we look
Then I'm getting these two values
So, guys, this is your inner joint
You must have gotten a rough idea by now
MATLAB
do tables
What kind of values are there in your mind?
what is common
whenever I need it, all at once
We call this the inner joint.
You can see it here
Don't worry
We'll see for ourselves through practical experience.
Main, right now, its proper definition
I will share it with you
You can see this, guys
What is the inner joint saying?
inner join returns only the rows
that match in both tables
What is it returning?
only rows that match in both tables
where we have the keyword se
We don't know anything important keywords
as joint
Basically, you write the joint
If you leave SJT behind, then
By default, the inner joint is high.
In this case
combines rows from two or more tables
using a related column
What is this joint doing here?
Do you have more tables?
is joining
is combining
based on some related columns
Yes, it is important that
whatever with tables
You're trying hard to join the group, aren't you?
in all tables
There should be a field like this.
mostly your primary one
and then foreign ki
What is common?
And inside it, your inner joint will come in.
returns only the exact matches
shared by both tables
in which we have to write them down
defines the column match
that connects the tables
You will know it soon.
and it is a table alias
What is this?
It's working like glue.
if you have two tables with
You're playing.
in table A
Which field was that?
It matches with table B.
just as in our field
users hi
One second
If we go here
right here
Select Star here
MATLAB everything
from table A
We're talking about MATLAB.
inner join
That's the syntax, by the way
A ko ab mujhe B ke saath
want to join
where these keywords are
He had come earlier.
What does the main tell you
It's my work.
Show these fields here
What is common between the two?
We said that
Which ID is on the table?
and B's table's ID
Yes, that's common.
On the basis of that, please give me
Provide the data
Hey, look at this
What is written?
returns only rows
where ID exists in both tables
MATLAB
It will return only those rows.
where this ID is located
It is matching.
You will find out soon enough.
Don't worry
and here too mapping
into SQL
Of what date?
Table 1
Table 2
our department
and inner join
Why only 2 and 4?
because only 2 and 4
What is common in both sets?
You must have seen it by now.
It was in Table A.
but it's not in B
That table
Table B
I mean, set me that
But it's not in the Wo A wale.
Who is Tari?
so guys
Look at this diagram.
How easy it becomes
because we have
in the back of the house
Who was Tariq taught by?
theke
Look here
so syntax here
You are very clear
You can see it
so this is your
part
a little while ago
We wrote "star"
select star
MATLAB everything
But we didn't say anything
Now I need specific
column desired
specific fill wanted
Who knows
in a table
only 20 columns
then to me all of
Just a little bit is needed.
right
so from table 1
table
Hi there
from table 2
and then
This is your own
Then just look here
select
from
inner join
and then on
Who is this historical figure?
It works.
choose the column
you want
from
Kwansa table
inner join
Match Road
that exist in both
table
define the key
in a relationship
It's very easy.
Then I'm here right now
You can see an example.
select
users
dot name
MATLAB
from the users table
I need a name
from the payments table
The one with the amount
need to fill
from users
His alias is Ek
given
short form
inner join
payments
on
User's table
id
and yeah, about ours
In the payments table
User ID
These two
fill
whichever row
It will be common.
His data is ours
It will happen.
This is simple.
and let's take a look
What is this here?
So some best practices
Tips and tricks
ambiguous columns
Look here
Yes, this is very important.kbd You are a professional translator. Translate the input into high-quality English, following rules on accuracy, completeness, fluency, and format. You MUST translate the entire input text in full, with no omissions. Every word, phrase, and sentence must be translated. Do NOT partially translate. Do NOT leave any source-language words, characters, or phrases untranslated. You MUST translate all names, numbers, dates, places, technical terms, and titles with the highest possible accuracy. Do not omit, hallucinate, summarize, condense, or alter any content. Translate only the given input text; do not add or infer any content. Strictly preserve all original formatting, punctuation, symbols, spacing, and line breaks. Resolve ambiguity using context and discourse-level meaning. Prefer idiomatic, natural expressions in the target language. Do not add any analysis, explanation, notes, or commentary. Output only the final translation.
ambiguous column
What does it say?
I am telling you
It's so hot here
Yes, this is it.
ki
your users' table
What do I have?
It is called
Table of departments
I also have a name.
if you have selected
id, name
Left it behind
He's going to go crazy.
close close
name what is here
has written
This department's
To show
to me users
Show me the table
hi
then we have
this Venn diagram
analogy
Simple
That's MATLAB.
KI departments
in the table
Sometimes a user
assign
has not been done
Hi there
You understand, right?
this user
any department
They belong
I don't want to
to
He will never see it
Hi Nahi
You
inner join
me
You understand, aren't you?
He will never see it again
Hi Nahi
because of that
It doesn't match.
at the end
We have always
Just like always
You can see it
Practice for you
Questions are there
to please
You do it yourself
I'll try it.
We are accomplished.
It is going.
love
Is Jage pe
Here
Well, then us
Alright, let's tackle this.
map
Look here
First of all
Here
aap clearly
You can see it
what we have
We have one.
question
from that time onwards
where
soccer ball
we want a
list of all
professors
all professors
Give him the list
need
but instead of
seeing the
Look here
Professor's list
We'll show them.
because users'
table me
calmly
I will get it for you.
but you
me
ID card
I don't need it
me
Your name
need
You understand, right?
Just look here
list of all
the professors
Who is that person?
departments
They belong
are there
right now
if I only
Users table
use karunga to
I need this, you know
It will happen.
whole for whole
This one here
Part N Name
but here
me department
I'll meet you
Name not available
Milne wala
to here
One join
Oh, really?
simple
use case
This is it.
where
You have two
yes, two
More query
I have to write
Here
if you use
join
to
one
query
to
wo
work
heart of the matter
You understand, right?
That's it
the biggest advantage
hi
How come?
Alright
Seen
let us
I'm here right now
It's done.
normally
if I use
card
me
are
professors
name
need
oar
If I didn't need their name, what would I do?
select
The option won't come anyway.
department
underscore ID
Alright
from
users
Ya
Okay, where
Role is also important.
where
role
equal to
Give me the single, please.
Alright
And this is it, your professor.
Look, our run has already been completed.
But the data hasn't arrived yet
I think he's the professor.
This perfect sea
Look at this
Check this out, guys
The data has arrived here.
How comfortably
There's been a big problem, hasn't there?
That is not the name of the Department's SIP ID.
Here it is now
I need to perform another query
Here, take the table from the department
And the relation between both of them
Here, the department's ID is equal to
By our way like this
I mean us
Had to run more than two queries, huh?
Here
Where you've found out
The ID that Department has
He is in the users' table.
And the same ID is ours in the department.
It is also in the table
So why not just write two queries instead?
I'll join both of them.
We first read a problem here.
ambiguous column OK
Now look, I've already written the name.
Now, this part here, which is the same as ours
It's also on our department's table.
So what should I do now?
Is it a user here
users.name, and here I will do it
We do this as a task.
as department
And I'll make it the name.
Take an alias name
And here it is from the user
as it will remain
Because look, you from users
Write here, this department does not handle this matter.
But somewhere deep inside, we know that
Here, the main primary table is our users.
Is it not?
Now you will have to write.
Here is inner join
Who to join?
I need to perform an inner join
Join the users table with the department table
So department, you are with this kind of
Write down departments
Okay, is it a department?
It's fine here, department
Now, below this, what is most important is
That is your own keyword, I said.
The one that performs the task of joining two tables
How with the help of common field
So in ours
Which field is in the users table?
That is your department ID.
will be equal to
You've already told me about the users table.
same as what is in the departments table
in the departments table
will be dot id will be
That's simple, isn't it?
Now look, where before me
Two queries were required.
My task will be done in one query now.
I'll copy it this way
I will run it, and something is wrong
Department of Transportation name
and department
That's exactly what it means
"departments" is a spelling mistake.
There's no other problem, it's fine.
It should be the same or perfect my output
It's here now.
list of all the professors
with their department name
Not department ID, it has come to me, this
So this is your inner join
Now you might think that we have
Why didn't we use left join, right join
So it makes no sense at all
I have two tables.
Between those two tables
were common values of the professor
One is their name, and the other is who
belongs to the department
I needed the data, meaning the data between the two of them.
This is common, right? So that's why
We have this inner join, and Funda, you
Got it, it's the same, these two lines
Extra is being added when we join.
If we talk about it, these two extra lines
is happening and that's your inner join
After that, you have to write that table
Brother, you to me this thing
I need to add it; you have to join this table for me.
Yeah, and in me, it's just you making this
Make sure that the table which is your primary table is
and then the secondary table that you have
Which fields are there in both of them?
is common, which both of you对其真实
I want to connect, I want to join
That's it, it's done.
That's all, now right here
What was happening was that every time you had users, such as
I've got a problem, like departments
I've written it down exactly here, but here I'm supposed to
A problem has arisen, even here too, then
Now we can do a task here
Those departments, departments
Every time I write, I'm reading it, now we have one more
An alias name can be very easy to give, such as
What is written here?
typing users and courses over
and over becomes tedious
let's use table alias
to find out
Which professor is teaching which course?
Okay, interesting. So here at
It has simply been said that however many
Who are the professors teaching which courses?
His data is needed for this, okay
With the help of alias, look how
select
professors
If you're studying the course, then basically
users.your阳
name, All right that
by default will be named, then
from the courses table
Will be needed, courses.
title and do a task, their
from your users
Alright, now let's talk.
Need is not required; it's your inner join.
and that's obviously
The table of courses will appear here.
and this is very, very important,
I'll say, yes, brother, the table of users
Which ID is it?
Let me remember that
The courses should be equal.
Our courses
By doing it like this, instructor ID
select everything
table from your courses
What will happen then, will it happen to you too?
It will refresh, and I'll also get an idea
Instructor ID
instructor_id
Alright, okay, it'll go, now here it is
Professors, look, where clause writing
We don't need that here now, right?
Because this ID here
and the ID of our instructor is
If it matches, then automatic
You'll soon realize what's going on.
Here, if I run this
Look here, root!
There are so many professors here.
Just look here.
Biscuitly, this one here is the same
Professor, isn't it? Two two
So, gas is this, your
Inner Zoin and by the way
What was supposed to be shown has indeed been shown.
I'm here, and that is the alias, right?
A secant
Alright, I'll copy this.
I walk below it.
So that you all may know here
Here, I'll do it for you.
Here you are, here you are
C, here it is
U, C
Gais here brings everyone together at once
There is no way to select it.
Tell me in the comments because I'm not trying
So, look ahead in this manner
So this is your alien, and how aged has it become
I am representing you, the user, to you.
Courses from C to
U. Name, C. Title, Basically now
This is Jadhag Aji, this is Jadhag Aji.
Vaccines and the next ones
Navshtra World
Now, look, up to now you've got two tables
They were playing games, but now it's like this here.
You have to play with three tables here.
Your human student has no other life condition than yours.
Why are you unenrolled from life course?
Whatever needs to be done here, after the lecaros, we have all been sent to Japan.
Now, look at our users table like this — the connection is being established.
To enroll in the inner courses, in the enrollments table,
The ID in the users table should match the student ID in the enrollments table.
So what happened by writing all this, is that our table for enrollments,
It's our students table, basically joined with the users table.
Now we also need to look at the courses. Here, here, a little doubt might arise among people, you know.
so that I can see users along with the courses they're enrolled in, meaning courses they've joined, using the enrollments table
You're going to be, just as I've written here, enrollments, I'm talking about the u.id, this aspect of on,
But if you look here, what has happened is, inner join courses c — this was supposed to be written anyway, no problem, this is exactly what needed to be written.
I need to join one table with another table, but in the 'on' clause, it matters which field from which table is being joined with which other table.
First, I said to join the users table with the enrollments table. Second, I said to join the enrollments table with the course table, where the course ID is this.
If you do it this way, you'll just get one data point here, PostgreSQL Bootcamp.
Guys, here, now I need to check, we're only getting one data point, meaning, there were around a hundred students.
Which course did they enroll in, speaking only, just one appears to me, isn't it, IUSS, doing one thing, right?
select star from enrollments, tickets, a bagwan, I guess day, day 12, or 13, I guess, there was one day, where we saw the enrollments table, the one with breez
And I just showed you inserting a single data point, and that's the only reason why I'm getting one data point; I'm doing this for you, I'll paste more data here, look here, it tells you everything.
I've already come here, and I've done it, run, perfect. Now when I run it, you'll see the magic—trii, too, wan, ant, bang, such a wan, this is it, look here, brother, this is how it goes, you see, output, look at this, whole thing, whole thing
Ananya Joshi, you know, once everything's here, you've seen two, you've seen three, you can definitely handle four too—I know you can. So, yeah, girls, that's it for this video. I hope you enjoyed the video, and I hope you've figured out the funda. Two, one.
If there are any conditions left, just keep them at the end, right? So, here is your inner join, where the matching rows from the two tables will give you the corresponding values right here. Okay, so, guys, that's it for this video. Hope you liked it.
If you haven't liked the video and subscribed to the channel yet, I'll be angry, and I'll see you in the next video. Okay, so if you're not going to do it here, and you're looking at two tables 商品 that match daily, okay, then...