 Dear students, today we are in the lecture number 31 of the database management system course. The course code is CS403. In the previous lecture, we were discussing the different forms of select statement. And mainly the main thing was that we were accessing the data from the same table. And at the end of the previous lecture, we entered into that part of the SQL where we can access data from multiple tables. And that is important. Why? Because I told you most of the time you will not find your required data in the same table. Rather due to the design reasons, to the design purpose, we have divided the data into different tables to include to produce efficiency in our design. So the user requirements, most of the time they cannot be fulfilled from the data of the same table. So it means most of the time you have to access data from multiple tables. And to access data from multiple tables, we have got different forms of joints. We have started access from the multiple tables by studying the Cartesian product. We discussed it in the previous lecture. Today we see what are the different forms of joints and how do we perform them and in what situation we select a particular form of joint. So let us start today's lecture. Inner join. Well this is something that we did not discuss too much in detail when we were studying the relational algebra. We studied there the equi-joint and the natural joint. Well inner join is a form of equi-joint. So you can consider inner join as a SQL format of the equi-joint. Well you saw in the Cartesian product that each row of one table is merged with each row of the other table. And we discussed it even in the discussion of relational algebra that in real life situation you won't find it very useful. This is not very frequent that we take the Cartesian product rather the logic is that if we combine those rows of two tables that have something in common and when we have something in common and we merge those rows then definitely there is some logic behind why we are combining these two rows. We will discuss in detail later. In inner join only those rows from both tables are merged that have same value for the common attribute. That is a equi-joint method implemented by different methods. We will see what different methods are. Common attributes need not to have same name but they must have same domain applied generally between tables having a referential integrity between them. The tables between which we have defined we have implemented the referential integrity constraint through the form key definition normally rather most of the time we apply the inner join on such tables. But this is not compulsory that is not necessary because you can apply the inner join on the tables that do not have the referential integrity constraint between them. But I am showing you this diagram once again. We have already seen it why I am showing you this diagram now. The reason is that I will try to explain the logic of applying different form of join between different tables for example if you see here. As I told you that we apply different types of joins when the tables have got a referential integrity constraint between them and generally we apply the referential integrity constraint between two entry types that have one to many relationship. In this diagram you see we have a one to many relationship between program and student. In the real life terminology we say that one student is enrolled only in one program and many students are enrolled in one program. So when we store the data about the students we store data about the students different attributes of the students plus representation of this relationship how is that implemented? This is implemented by including the primary key of the program that is program name into the student as the foreign key or we also define the referential integrity constraint so that only legal values are entered into the foreign key. Now the thing is what is the logic of joining different roles from program and student? Definitely we know the relationship between the program and the student that students are enrolled in a particular program. Now the thing is that if we access the student's data we want the enrolled program to have the data. Now obviously against one student we need to access the same program that the student is enrolled in. For example if a student is enrolled in MCS then there is no logic if we along with the data of this student we also see the data of the BCS program, the BIT program or the MBA program. So the real world with the logic is that you match those things, you merge them so that there is a link between them and in the terminology of the database or relational database or relational data model how is the link established based on the values of the primary foreign keys? So now when we talk about the inner join and the other form of join it is that the common attribute is between the two roles, it should be there because the join will be there only when you have got a common attribute between the two tables. Now the common attribute of the two tables is the value, it is linking the two tables and the referential integrity constraint is controlling the validity of the two tables. So these two tables will only meet the same roles in which the value of the common attribute is the same. Now if you see there is another beauty that if you see the primary key, the primary key in the table, see the reference in the reference of the foreign key table, so what will happen is that the primary key of the table can get a row of the foreign key side for a long time. But if you look at it from the foreign key side, because the foreign key is the primary key in the home relation, it cannot be that you get more than one row in which the primary key is the value. So if you look at it from many sides, like the foreign key, the row of the primary key side will get only one row. So you see that you will get that row in which the primary key is the common value. So the logic is that the link is related and how is the relationship going to be based on the value of that common attribute. Same is the case in our example database between the program and the course. What is going on there? What is going on there is that there are a lot of courses in your program and one course relates to another program. Now if you look at the Cartesian product between the program and the course, like we had seen in the examples, then every day of the program table, every day of the course, there is the logic in general. But the logic of this is that in this program, for example, BIT, which courses are included in the BIT program? So the record representing the BIT program, it should be merged with the BIT program in which the courses are included in the BIT program. So this is the logic, right? So it is obvious that from the system point of view, from the real system point of view, you will say that we will mix BIT with those courses which are BIT courses. And if we try to convey the same thing in the terminology of the database, then we will say that we will merge those rows in which the value of the common attribute is the same. Similarly, if you look at our example, we said that our course offered, which basically was our relationship, but we expressed it as an associative entity type, as a gerund. Now between this, your course offered and your student. The relationship between these is man to man. Now to implement that relationship, we made another relationship. When we transformed it into a relationship model, then we have an enrol relation. Now again, if we look at the enrol, if we look at the course offered and the student reference, then there is a man to man. But if we look at the reference of the enrol, then the enrol will be on the student's side as well. Similarly, if you look at the course offered, then it will be man to man from there. So again, how this will be done? Your one student will be linked with many instances of enrol. Because many of your enrolments of one student. There are many enrol courses, of course. So all of them will be recorded. And how this will be done? Based on the primary key of the student table. And all of your enrol records, in which this will exist, will merge with each other. Same is the case with the course offered. Even there, the primary key of the course offered is one to many linked with the enrol. So the primary key and the same value of the forum will merge with each other. So the purpose of all these explanations is to understand what is the logic of the join. And you try to understand this logic from the perspective of both the words. The real world in which we are implementing and the database world in which we are working right now. So in terms of real world terminology, we say that the things that are related to each other, which have a logic connection, they are linked to each other. Like I said, program, course. Student, program. Enrol, student. Enrol, course offered. And if we describe this in the database terminology, then we will say that the common attribute which has the same value on the places, will merge with each other. Not like a Cartesian product, but with each other. So this is a basic logic behind the join. And the different forms of joins have the same logic applied, but with some variations. We will discuss those variations, but it is necessary that you should understand the basic logic of the join. So some examples are also included in our slides. And when you get lecture notes, there will be different examples like exercises. The more you practice, the more clear you will be. And without practice, you will not be clear. Let us go ahead. For example, if you look at the screen right now, you have got two tables here. One table is the program table, where you have different programs that are being offered in the institute. There are five rows. And on the other side, we have the course table, where all the courses are listed. Again, the reason I have shown you these tables is that I want to explain to you what is the logic behind the merging of the rows. For example, if you look, we have the first row in the course, which is CS105 Intro to Programming, four credits, and the second row is B6 Programming. On the other side, the first row in the program is BBA, 8 and 130. Now if you look, if we merge these two rows, what is happening is that on one side, the row that is coming from the course represents some data about a particular course. And on the other side, what is coming from the program is saying something about a particular program. But the course is BCS. The program that is coming in detail, whether it is 8 semesters or 130 credits, 130 credits are from BBA. Now think about the logic behind it. If you merge a BCS course with BBA and look at the data, in general terms, there is no logic. So, it will not join with the reference of the join. The same is the case, if you merge this first row with BIT, with MBA or MCS, then it does not make any logic. It does not see its utility. From both the database point of view and from the real world point of view. So, if we look at the first row of the course table, the second row of the program table, if we merge it with that, then there is a logic. What is the course? It has its own data. Along with it, a piece of data is that this course belongs to, this course is a part of the program BCS. On the other side, if we merge it with the table of BCS, you will see that it gives you a more meaningful thing. Is this course a code? Is this the name of the course? Is this the credits? Is this the offer of the program? And the offer of the program is that much in total semesters and that is that much in total credits. The logic is that you have given further information about a course, which you have obtained from another table. But as I said before, if you merge this course with the BBS or the BIT, then that information or that data is not meaningful because there is no link between them and it is not related to them. So, this is the logic behind the joint. I hope this example is clear to you. Now we come again towards the inner joint. How do we do it? Set star. And again, rather than giving the star, you can give the attribute list as well. Any particular attribute, you can take it from both the tables. From course or this format is again of the SQL server. You said set star from course and then you said inner joint program. In Cartesian product, you said course, program. Here you said from course, inner joint, program. And the inner joint is written in capital. It means that it is required there as such. And then, how do you give the condition with on? On course. Program name is equal to program. Program name. Because the name of the common attribute is same in both the tables. So, you cannot write that program name is equal to program name. Dbms gets confused. What is this different program name written? Because program name is there in two tables. That is why you said you gave a qualified attribute name. Table name. Program name. Overall, if you see, these names become two different names. Dbms can specifically address a particular attribute. Because it knows that program name is in the program table. So, this is how you perform the inner joint in the SQL server. Another way to do this, which is commonly used, is that you said, select star from course C. Now, the course C is written here. You have alias. Because when you used the program name in both the conditions, you have to type more characters. You have to type a lengthier text. You can do this with alias. And then in the condition rather than giving the table name, you can give the alias. In this case, you have course C. Now, C is the alias for the course in this statement. Inner joint. And what you have given the condition on again, rather than giving the table name, you said C dot program name and P dot program name. And mind it, it is not necessary to alias the course with C. It is not necessary to alias the P with such a program. It is just a chance. And you can do anything with it. Now, look here. Here is the output. You can see the program name twice. And one thing you can see is that the program name is the same in all the rows. Because the program name is coming from the course table. And the second one is coming from the program table. You can see that rows are the same in which this common attribute is the same. And that gives you a meaningful result in this program. In this program, there are 30 semesters and there are so many candidates. So in this way, the data that you combined from different rows and merged it with a meaningful method. I hope you have cleared it. If we have used the inner joint command, how can we do it as you can see here? Select star from course, program. We have not used the inner joint phrase. We have not used the words. We have simply said course, program. But when we say where, now we are creating the inner joint using the where clause or by giving a condition. So what will happen? The condition is course.programname is equal to program.programname. The name of the attribute is called PRName. If it was different, one was called PRName, one was called PRR, one was called PR1. In that case, you do not need to qualify the attribute names. You simply call it attribute name. There are different names. Dbms will refer to the appropriate table to access the value. In this case, we need to obviously, we have the option to use alias here. Next form of joint that we are going to study is the outer joint. Now you have seen that the special thing about the inner joint is that both of your tables will merge with the tables in which you have the same value of the common attribute. Those tables will miss the inner joint. Because they do not have the same value of the common attribute. So, the outer joint gives you the option that the inner joint will also come and the outer joint will also come. So, the inner joint will also come and the outer joint will also come. Now, there are different forms of outer joint. Inner joint plus the missing rows from one or more tables. Left, right and full outer joints. These are different types of outer joints that are available. Right outer joint is inner joint plus rows from the non-matching rows from right table. What is the concept of right or left? When you write the direct statement, what you will write is the word outer joint. The left one is the table and the right one means that there is no need for distinction. The only thing is how you write your statement. The tables you write first, then write later, it doesn't matter. But this thing will definitely matter that which table you want non-matching rows. The first thing we have is course and program. First, between the course and program, you will get the matching rows but you also want to see the non-matching rows of the course. In this case, you want the non-matching rows of the course. Now you have to use the inner left outer joint or right outer joint. It depends on where you write the course table. If you write the course, then you write the course and then you write the program. You need to write the course because if you write the course before, then you write the course and then you write the left outer joint. Because now you want now you need or now you will get the non-matching rows of the table on the left of the command. But if you write the program first, then you need to write The course will come later. So the words of this command are coming on the right. Then you will write for the same thing that this program and right outer join course. This way you can do one command from the right side and keep one more thing here, K. What I am telling you repeatedly, this is the approach of the SQL server. If you use any other tool, then maybe there is another approach. But again, the meaning of the concept, they won't change. Meaning when you have an outer join, it is an outer join on every place. This is what it means. The left outer join is an outer join on every place. Because this is the part of the theory of the relational mathematics. So when you have a right outer join, it will remain on every place. It won't change. But how will that implement? This is the DBMS specific. It can change the way a DBMS implements it and the other DBMS implements it in a different way. Left outer join performs the same thing but missing rows of the left side table. I have told you the same thing. A left outer join B will give you the same effect as B right outer join A. On the left side, you said that A was first written and you said left outer join. So inner join plus A's missing rows. And on the other side, you said right outer join and one on the right side. So that will be the same effect. Missing values are replaced with nulls. Meaning if you are non-matching, then only one value will come. What will be the other one? It won't come. Now where you don't get confused we say that primary key can't come. So how will this null come? Because the output that came in here as primary key function is not working. I will explain this in an example. Full outer join is the inner join plus the non-matching rows from both tables. Full outer join will be in every case. In any form of outer join. Now the one on the left side will be left. The one on the right side will be right. And the full outer join will be in both tables. For example, you said that select star from course C C is the areas. Left outer join program P is the areas. On C dot program name is equal to P dot program name. Or you can do this in other ways. Select star from program P, right outer join. What we have done here is we have written the course program first. Because the course went to the right. Now it will be right outer join. And both the effects will be exactly the same. And your condition is now this is the output. If you look at this. So we have row number 8. In which is MG103 intro to management. Now this course was like that was not linked with any program. Because all the other courses that were recorded. They were linked with some program. Because their program name is foreign attribute. There is some value in it. There was null in it. Null means that it does not match with anyone. When it does not match. So obviously the gains that you will get from the attribute. From the program table. All of them are null. Now there is a problem. The program name of the program table. That is the primary key. And we have said about the primary key. That it cannot have null. So here the program name attribute. The program table. There is a null in it. The answer to that is as I told you before. That the program name here. It is not functioning as primary key. Because you have the output. The join is coming. That is why we can have null in it. In another course. Select star from program P. Left auto join course C on program A. And you can also see this. Select star from C. Right auto join program P on C. Dot program name. And see what is happening in it. That you have done the same thing. That you have reversed the order. That is exactly the same. But what is happening in it. That you have the program table. That you are getting the missing row. That you are getting the null matching rows. Now we have in the program table. How was the MIT program. Which we have not defined any course yet. What is happening in it. If you see that we have the last row. MIT is coming in it. MIT we have a program. It has 4 total semesters. And it has 62 credits. But. Because we have not done any course. So that attribute. Which has come from the course. In this inner join. So in this way you can see. How can we take any non-matching table. How can we take any non-matching table. How can we take any non-matching table. Outer join. The last form is the full outer join. And that is the select star from program P. Full outer join. Course C. And the condition is on. P dot program name is equal to C dot program name. And the output of it. Is this. If you look at it. Row number one. In this you can see. We have the course. MG103. Intro to management. It is not linked to any program yet. So we have those. Those programs are three. Similarly. Which we have the last row. In which we have MIT program. Which we have not done any course. In the course table. Which is also merged. So all your attributes are merged. From course. So this is the example of. Full outer join. Again. Tool specific. Semi join. First inner join. And then projected on the attributes of one table. Advantage. Tells the rows involved in join. All the examples we have seen. Until now. We had two different tables. We had a relationship. And we joined it. So in that. Certain rows from both the tables. Are merged with each other. So in that. Which rows match. Which common attributes are the same. Now. The semi-join. Does that. And after that. Will be. On one table. But it. Projects the result. This is what it means. See. Your rows are merged. Which were common attributes. Its value was same. When we. From that inner join. Only those. Attributes. Which belong to one table. What is its advantage. Its advantage is. From one table. Which of the rows. Which of the records. Were involved in this. Or. Which were linked. This had description from the database point of view. If you see this. From the real-world system point of view. So if we see. The program. And the course. If we take the semi-join. Let's say on course. It will be the inner join. Of course. Of course. Which are linked. With the program. It will be merged. After that you will remove. Those rows. Which are of course. Its advantage is. Which courses. Whose programs are defined. Or. Which courses. Which are being offered. In some programs. In the same way. If you take the opposite. That we said. Program. We took the course. We took the inner join. And we projected on the program. This will be. Which of the programs. Which are involved in this. Or. Which of the programs. Between the programs. So. If we take the semi-join. On the student. Which students who are enrolled. Or if we take the semi-join. On the program. Which programs. Which students enrolled. So. You get the information. That. The inner join. Will be. No operator available as such but can be implemented by select list as we have done before. Look at this example, like here we said that select distinct p.program name total semester or program credits from program p inner joint course C. Now, look at the first thing in X, we have written the district so that if there is a duplicate then it is not there, after that you can see that the program name attribute we have qualified with it, we have added the name of the table from it, the reason is that the program name attribute is also in the program and in the course so if we only write the program name then there is a confusion. But the total semester is program credits, we know that it is in a single table that is why we do not need to give a table name to it. And look here we have done that we have given the inner joint as the second part is telling and we have taken that attribute from it which belongs to the project table. So we can say that this is the program semi-join course. And here is the final part of this statement, here it says on p.program name is equal to C.program name. So the later part it performs the inner joint and the initial part it performs the projection. So both together they give the impression of the semi-join. And look at this output. Now look at this screen you are seeing five records. This means that these are the five records of your program table that are involved in the relationship with the course. Or you can say that we have defined the course table of these programs. You will remember that in this program table you have got another row, another record that is of MIT program. And because we have not introduced any course of the MIT program that is why we are not seeing MIT record here. Because it was not the inner joint part and we took this projection from the inner joint. So you will not get MIT record. This is the last form of time that we are going to study. And as the name suggests in this form of joint, table is joined with itself. And idea is the same that the primary foreign concept will be used in this. And the difference is that first we had primary in one table and foreign in the other. Now you will see that one table's own attribute that would be working as a foreign key. As we had studied earlier in the unary relationship. You will implement the self-joiners in the place where we have implemented the unary relationship. Or recursive relationship. Now it will be that you will define the foreign first. And you will link it with your table. And then when you implement it, the first thing you do when you declare it as foreign key. So the attribute of that table that you declared as foreign key. When you enter the value in it, then DBMS will also ensure that you enter the same value there. Which is already entered in the primary key. Now there can be many examples of this. For example, if you see that we have an employee table. In the employee table, we have the record of all the employees. One of them is the manager. So a particular employee of different employees is the manager. First we have different departments. First we have 15 departments. So every department has a manager. So if we have 1000 records, 1000 employees. So among the 15 people are the manager. Now the one who has declared as a manager is the foreign key. And the one who is referring to this table is the primary key. So what will happen in these 15 foreign keys? It can be null, it can be anything. But the rest of the records will be in the foreign key. One of these will be the primary key as the manager. So this is how you can view it. If you look at the student like this. For example, we will add another attribute in it. We call it CR. We have different students. And different classes as you know are class representative. So one student will be declared as CR. So we will associate who is the CR of this class. So we will add a attribute in it which we will declare as a foreign key. And then we will join it with it. Let's see how we will do it. Applied on the same table having reference directory constraint implemented onto itself. Here I have given the alter table statement as a surface layer. Because till now we have not added a attribute in it which I have also called CR. So to add that table and to join the reference directory constraint I give the alter statement here. So we said alter table student and add CR. It is a attribute name and its type is character 5. And obviously I had told you that the primary key and foreign key domain should be the same. Because we have the student ID. Its data type is character 5. So the type of CR we have declared is character 5. And also we have given references student and student ID. So we have added it. And also we have declared it as foreign key. And the home relation of foreign key is the same table in which it is contained. Now let's see what we have done here. What we have done here is that we have entered the data. If you see that the first row we have here is S0123. Its name is Amjad. It is enrolled in MCS. The CR itself is CR. So there is no CR here. But if you look at the second row which is MCS then its CR is S0123. Now S0123 is the ID of the Amjad which was on the first row. Similarly if you look at the third row there is a record on the third row. And its ID is S1015. Because again, TAHRA is enrolled in MCS. And the CR of MCS that we have declared is Amjad whose ID is S0123. So here it will be S0123. Similarly we have the fifth record of Sweldar. This is also MCS. So its CR attribute is the same value here as S0123. Or like that. So if you look at the same table you have added an attribute to it. And you have also imposed a Referential Integrity Constraint. This will give you the same values which are already present in its primary key. So this is how you include a Referential Integrity Constraint or you include a foreign key into the same table. That reference is the same table. Now how to take a self-journ? Let's take a self-journ. We have said here that selectA.studentId. If you look at the select list here all the attributes are qualified. The reason for that is because we are taking the self-journ. So whatever attribute name we take it will be present in both. What does it mean by both? Since we are taking a self-journ. A table of our own. So logically you have to understand that whatever table we have as a student in this case you have to understand that a student is living twice. Logically, theoretically, not practically. Practically it is the same. But you have to suppose that you have to make a house in your mind or you have to think that the same data we have, the same table is living twice. This is exactly this. You can call it A or B. So at the time you want to write your select list or you are mentioning the condition in any case, at the time you refer to a particular attribute then in your mind what should happen right now at this particular moment at which instance I am referring to an attribute at which instance of the table came from this or from this or from the one I called A or from the one I called B So if you understand two instances of the same table in your mind then it will be easier to write a query. You can visualize both of them as to separate tables whereas practically it is the same table. Now see what we have done here that the select list we have we have used all the names we have used which are qualified that is we have given the alias name and basically the objective of this query is that we need all the students' ID and we also need the name of CR so what we have done is select A.studentID A.studentName B.studentID B.studentName Now think about this that we have one table from there we are taking the student's data and from there we are taking CR again we have two instances of the same table we will pick the student's data from one instance and from the other instance we will pick the CR data so what we have done here we have said from student A and from the same table student but the other alias B where A.CR is equal to B.studentID Now this means that the one instance which we have taken the CR attribute the value in it you hold it and match it and go to the other instance and match the student ID attribute of that instance again pick the CR attribute of one instance and match this value with the student attribute of the other instance so from here you are picking CR's value and looking for the student based on that so this is the output and see what is happening here because we have four enrolled people in MCS their data is present here and we have CR which we have declared as MCS class so the first thing is that we can only see four recorders here which are all students of MCS and after that we see for all these four they are different students but if you look at the other part where we talked about the CR because CR is the same there are five records and one of them is CR and the other four are students so there is no CR that is why it was not kept there but if you look at the other records then we have the same student record in which its ID is and the name is less so the two columns on the left are telling you the student's name and the two columns on the right are their CR's ID so because we only have CR defined students of MCS so here you are getting only students of MCS if the other programs are defined then we will get them so far we have discussed different forms of joins and we have seen that we can access from multiple tables we have seen Cartesian product inner join, outer join, semi join and even self join and as I told you before practice it and I will also give you the different queries that you will get when you practice then you will get clear one more important topic of SQL we are going to read and the basic idea of sub query is that you use another query in one query sub query query within a query now the question is what is the query on which stage can we give another query in one query where we have read different syntax, different formats there is an expression on which expression can come you can write a sub query there but generally what we write sub query we write where clause where we apply the condition normally we use the sub query and one more thing is that there are multiple options for example in one place you can do sub query that you can join and vice versa you can do sub query it is totally up to you your convenience is also involved and secondly when you study some depth the efficient approach you will get when you read this you should know that you can do the same activity with different options you can do what suits you at some particular time we are going to read all the queries and as I told you this means that there is another query in one query a query within a query useful when condition has to be applied against an unknown value yes this is the hint this is the tip so you normally know that what is the value of the condition what is your required condition for example you said program name is equal to mcs department is equal to this you said name in this when you know what is the condition what are the values in that case you use where clause but when you are not clear what is the condition then in that case you use sub query for example you get the names of two students who have more cga than that of maximum of bcs student now the students of bcs whose maximum cga is more than those of cga now you do not know that the students of these students what is the maximum cga this is something unknown so in the query you will first apply a query that will take you to the maximum cga of bcs and you will make this query as sub query and you will apply another query which will compare with this so you use a sub query like this can be used anywhere where an expression is allowed you can use where clause and can be nested like that careful about operators yes depends whether sub query returns single or multiple values till now you have read inco or like or between and where your operator is equal less than greater than so when you are using a sub query you have to see how many results we will get whether it will be single or multiple values if you are sure that the result will be single in that case you can use operators like equal less than greater than equal to you can do this but in the case where you know that you can not use equal to in that case we have operator in any inco or all in any all in that case when the sub query returns multiple values for example select star from student where cgpa greater than greater than symbol it is necessary because cgpa has a single value that you can compare only with a single value if your sub query is giving multiple values then the greater than symbol becomes useless so when you have used greater than operator then you have to make sure that the result we are getting is single value here we have given sub query in parenthesis we have said select max cgpa from student where program name is equal to bcs now what will happen as I told you before where will restrict that will pass toward the aggregate function now that will come out where your program name is bcs that will apply your maximum aggregate function and it will return you a single value that value will be compared with cgpa and your result will be structured so this is an example of the sub query here you have an example of this you can see one more here although we have used aggregate function we have also used the group by clause in your sub query you have your row is a group and in every row you will get a value so any show that your cgpa if any of the multiple values are there then it will be selected so this is again when you get multiple values this is output that is it that we have to recover about dml in this course and the golden rule practice makes even the students perfect you can go from practice without practice you cannot be perfect after this we have dcl data control language and this is very easy because diy means do it yourself dear students in today's lecture we have concluded the dml part of the sql and we studied right from the select statement we studied different forms of select statement right from accessing data from a single table we studied data access from the multiple tables then different forms of joints and finally we have read about the sub query here our sql discussion is finished your dcl I have left the stage because there are few statements revoke and grant you can do it yourself and it is not that important after this we will end our sql discussion and we will go to the next topic till the next lecture Allah Hafiz