hello guys welcome to my channel this is
the 29th tutorial in this course and in
this tutorial we are going to talk about
SQL joints now those of you who heard
things about joins like you know joins
are really difficult and you know it's
impossible to master joins and all those
things you know I guess you would have
to put all those things at the back of
your mind for this tutorial because
joins are extremely simple but very
powerful and you know at some point of
time in your life if you want to make a
career as a database administrator then
you would have to learn joins and also
use them extensively right now work for
an MNC of five months as a database
administrator and all I did everyday was
just used as to a joint and pull out
stuff from tables right so the reason
why SQL joins are popular and so
powerful is that joins allow you to pull
information out from more than one table
right so for the sake of this tutorial I
have created another table and I've
given that table the name tutorial
underscore info so we've seen the
tutorial table in you know the previous
tutorials and let me show you guys the
data that I have in that table so for
that I'll use the Select query type in
select space star since I want to see
data in all rows and from and then the
name of the table which is tutorial put
in a semicolon at the end when I press
control enter I see that this table has
got ID field and title field subject
field duration and applaudin scored date
so in ID I have got a unique number for
all the rows in the table and the title
field holds the title of the tutorials
and subject field holds the names of the
playlist so I've got SQL C in shell
scripting and then duration holds the
length of the tutorials in minutes and
then uploading score date field holds
the date on which the dear old was
uploaded right so this is the tutorial
table and I have created another table
in this ones tutorial underscore info
and this holds information about you
know the number of views for each oil
the number of likes each oil has and
dislikes and shares and you can see that
I have a column in this table which is
tutorial underscore
or ID and it holds a similar information
as the ID column held for d2 role table
right so it also has a unique number for
each row and well this row actually
corresponds to you know the first row of
the tutorial table right so all this
data that you see you know 15,000 views
and 54 likes and 13 dislikes and 6
shares this data is for the first
tutorial or the tutorial with ID 1 in
the tutorial table now let's say you
want to see all this information as well
as some information from the tutorial
table in a single result set and you
want to pull all that information out
you know through a single SQL query well
how are you going to do that because
till now all these select queries that
we've seen in this course all those
queries have just pulled out information
from one table but here we want to see
you know views likes and shares from
this table and we want to see title
duration and subject maybe from the
tutorial table so you know if you want
to do such things and you have to use
SQL joins and the way you're going to do
that is you'll have to use the Select
query of course and you will first type
in the columns that you want so let's
say I'm going to refer to the tutorial
table as T right and we're just going to
use aliasing and if you don't know what
that is then I would suggest you to
watch the previous tutorial in this
course in which we talked about the ask
laws but I'll just type in T dot and
then the name of the column that I want
from the tutorial table so I want ID
from the Detroit table and then I want a
let's say title and I also want duration
okay and then on the next line I'll type
in the columns that I want from the
tutorial underscore info table and I'm
going to refer to the tutorial
underscore info table as Ti so I'll type
in t I dot view and then T I dot likes
and then T I dot shears and I guess
that's that's good enough and then I'll
type in from on the next line and then
I'll type in
tutorial right and since I have referred
to the table tutorial as T in the kawaii
thus far I'll have to instruct test
whether I have done that and for that I
will use the as clause I'll type in T
here and then on the next line I'll type
in the keyword join right and this is
going to instruct SQL that well all this
you know information that we are looking
for this is not present in just the
tutorial table but let's present another
table and the name of that table is
tutorial underscore info and since I've
referred to this table as Ti I will type
in a space t I here and then on the next
line I will type in another keyword and
this one is on and what this keyword is
going to do is it's going to tell SQL
that you know this joint operation has
to be performed on some condition and
that condition is that we want you know
data from both the tables for those rows
for which the value in the ID column in
the tutorial table is the same as the
value in the tutorial underscore ID
column of the tutorial underscore info
table right so it may sound complicated
but if you just think about it then it
will all make a lot of sense so the way
I'm going to write this condition is
I'll type in T dot ID and you know it
should equal the i dot tutorial
underscore ID right I'll put a semicolon
at the end and when I press control
enter I see that I get a result set in
which all this information is present
right so I have the ID column and then
title duration views likes and shares
and now I can see the number of views
for the Select query tutorial number of
likes for a number of likes for the
insert query table without having to
execute the Select query for both tables
separately right so this is about SQL
joins and there's another way in which
you can perform the join operation and
that's actually the more used way and
also the less preferred way and you know
this is this is the right method
actually and you know this is the method
that you would see you know professors
teaching in universities and you know
the method discussed in textbooks but
the more used way of performing SQL
joins is you you remove the join keyword
from your query you just have your table
name so tutorial as T then you put a
comma and then you type in the second
table name tutorial underscore info as
Ti and then on the next line on the next
line you type in where right so you type
in the where clause and then the
condition so that would be T dot ID
equals t i dot tutorial underscore ID
I'll put a semicolon and when I execute
the query I see that I get the same
results that there's nothing different
in this and you might think that this
query is the same as the previous query
but actually they're very different but
you know you can you can actually learn
through anyway but it would be great if
you you know practice the previous query
more and you master that more because
you know that is the recommended way of
performing the join operation right so
thank you so much for watching this
tutorial and you may subscribe to my
channel and I'll see you soon