Today we are going to discuss about the joints, how join works and what are the joints in SQL. A join clause is used to combine rows from two or more different tables based on a related column between them. How parcels This is the students table. As you know, we are working on this table. And we only have or we only have a single table. Now, first of all, if you have a second table name classes, you know very well that every class has a particular name or number, then is to learn and set or enroll in that class.
Or if you have a subject table, then you know very well that every subject has a name and student can enroll in that subject. J and this way Okay, so now if you are getting the results from both table so that time you need the tries to combine the results to fetch the results from two different table. Make sure based on the related column between the two we'll discuss about the primary and the secondary key. But for now, I am going to create another table. So we can use a join. Okay, so now I'm saying I have create a Will you know very well about the syntax and saying subjects.
And now all I'm saying table as you can see, it's giving you the structure personally given upon you how you're looking for The Greater Good give you some heads. So now I'm saying that that they will leave his subjects. And the column name is I'm saying as ID that means I'm talking about subject it is indeed here make sure I'm saying is it's not null. And also it's offering free will key and make sure it is surprisingly key. Okay, semicolon. Sorry, comma.
Now I'm saying as name that means I'm talking about the subject name, I'm saying March or 250. That means it this column in hold 250 characters, not more than two. If you have more than 250 characters possible if you have 501,000 or more than 1000 characters, you have to use the text Okay, now, I'm saying that the student ID, why I'm saying student ID, because we are going to add the student ID in this color so we can make the relationship and we can use a jumbo join functionality of, Okay, now I'm saying NDA first of all is not null. Make sure every time you have to provide this value while adding any Oh, okay, now I'm saying this is s ID, s name, and student ID, okay? Okay. Now I'm saying Control Enter, you have successfully created the second table, make sure we have not define the secondary key or the relationship between the smartphone now I'm saying select.
I'm saying So, so tables, so tables. And all in there. As you know, it's currently showing you two tables you have you already have students table now you have just created a subject table. Now I'm saying, I'm going to insert the records in that second tables. So how, but before adding the before inserting the row or the result in the subjects table, you have to familiar with your student table possible and saying select his favorite from students and volunteers. So now as you can see, you have the john ID.
Now I'm saying I know a little bit about the ID. I'm saying insert, insert into subject. subjects. Now I'm saying the columns are I have just created the column. assay, that means this subject name, and now the second one is s ID sorry, not as ID, student ID. And the values are.
Now I'm saying possibles. PHP is a subject name, and the age student enrolled in this subject. to terminate the statement, use a semicolon. It's a best practice to use a semicolon. Control Enter basically a query. Now I'm saying select static from students.
So as you can see now student, it is time for subject to enter presidency residency, you have added the record here. Now I'm saying I'm going to add In the third record now in this time the student is 9am saying is also in role in this role in that. So nine is it No, not well, well in this table select very little impact. Okay, nine is available. Now I'm seeing PHP and nine in there. So we have inserted now I'm saying select is reading from objects Ctrl Enter We have added the second.
Now, you know very well that you have one cup one table which is the student and you have just created a second table. So, in our later lectures we are going to discuss that how can you get the results by combining two tables using trace so For now, I'm just telling you we have different types of join, initially left join, right join, who will join we will discuss about the join dp in our little lectures but for now we have created a table. And now you know very well that when you want to retrieve the address or the data sets from different stable, we use the tracks. So I think this is enough for the next session we are going to cover the device. Thank you for watching.