I'll call you back again to our end of the lecture in my sequel.
And in this video lecture, let's go ahead and look at the views in MySQL.
How let's go ahead and move over here.
Go over to your table.
You got a table if you want but that is no problem.
And on a database go down here you can see we'll have what is called views.
Views.
So these views are very important.
Yes.
What is the use of views in MySQL.
That is very crucial you ask me.
So views are virtual tables like we create these tables right in here.
We can create a mural or a virtual table and a mirror or everything we have right in here.
So this table will have employee table or distress table everything to computer that's right in here.
And any changes we do in this table or in table or any of our table here will we actually reflect on
the view table without touching the view table.
Yes.
Now let me go ahead and say give an example of how this works.
So you have a stress table and someone comes in or actually comes in and says I need a stress attendance.
And you are not going to add that right in here because the attendance might always change.
And, uh, what are you going to do?
You don't need to create other stress table.
All you need to do is to mirror this stress table into the views table.
And that creates what is called a students attendance.
And that is going to be under the views table.
So you can actually drop that attendance list for that particular uh lecture.
And another lecturer comes, you create another attendance list.
So without altering your students table.
So in that way the student is always saved.
But whatever we do in the stress table, we actually reflect on our attendance table which is under
the views.
So the views are not real, but they can we can interact with them from the real tables.
Now let's go ahead and create a student attendance table and see that how it works.
So let me go ahead and say I'm going to create view.
And then I'm going to name my view to be students underscore attendance.
All right.
So our underscore attendance as then you go ahead and select the score here and select the first name
of our students and the last names right.
So we're going to say first underscore name and our last underscore name.
And where are you selecting these.
You're going to select that from a table.
So you go ahead and choose a table I'm selecting that from my students table.
So I'll go ahead and say from students.
And the place is semicolon now because I create what is called view with this keyword view.
It means I'm creating a table from a student's table.
Because you selected I'm going to create this from the students table.
So you can actually select maybe from the employees table, from subjects or from teachers depending
on whatever you want to do.
But here I want to take student's attendance.
I want to take the attendance based on the students table.
We just want to mirror this on their views.
So I'm going to work with it and maybe present that with our students table.
Go ahead and execute this query and check it out.
Now with this go ahead and refresh this and check it out.
Now what's your views.
You can see we have what is called students attendance and the attendance.
You can see first name and last name.
Wow that is cool.
All right.
Now let's go ahead and check out our students attendance table.
Go ahead and select all From strains on the squash tendons and semicolon at the end.
And go ahead and execute the query.
And you can see that now we are selecting what is called students attendance and not student attendance.
I must do this alone.
So we have a table called attendance and that is under the views table.
So from here you can present everything or this attendance list to anybody that requested that.
We talked about your students table.
And you can actually go ahead and interact with your student attendance table by using some keywords
in the previous lectures.
Let me go ahead and say I want to order these by alphabetical, just like we do or done by.
Go ahead and see order by.
And let me see.
Um, last underscore name.
And then why not put semicolon at the end.
Okay.
You can actually make this to be maybe ascending order or anywhere.
Maybe be ascending or descending order.
So if we do that, you can actually go ahead and uh, say order is not a valid keyword.
Oh, so this is our AC.
Okay.
And that is all.
Okay.
So I have an order by this.
So all I need to do is that I'm going to select this.
So I replace this.
So go ahead and place this under here.
So what happens is I'm going to select all from students attendance.
Then order it by the last name.
That is what I wanted to do.
And I was putting that above that and execute this query.
Let's check it out.
Now you can see order by last name and by ascending order.
All you can see here is Harry, Joel, Rocky, Sam and smart.
All right.
Now that is by the last name.
So you can actually do that by first name.
Go ahead and say first underscore name and go ahead and check it out.
Barak, Mike, Oscar, Peter, Quinn, Sarah and Zendaya.
So you can actually interact with all these.
And you can also drop your, uh, views table.
All right.
Let me go ahead and show you how to drop the views table so we can actually, um, see how it works.
So after I interact with the table and everything you need, you can actually go ahead and say, I want
to drop the view table.
Let's say drop a view.
And you name your view table as a student's attendance and semicolon at the end and as a previous query.
And now go back here.
You can also refresh.
You can see that the view table is no longer there.
All right.
So this is about a table.
I'll give you one more example in the next video lecture.
So let's go over to the next lecture and do one more example.
That is very interesting.
So see in the next lecture we will go ahead and share more on the views and MySQL and uh hope to catch
you there.
Thank you and see you in the next video.