WEBVTT

00:07.910 --> 00:10.460
I'll call you back again to our end of the lecture in my sequel.

00:10.460 --> 00:15.380
And in this video lecture, let's go ahead and look at the views in MySQL.

00:15.770 --> 00:18.590
How let's go ahead and move over here.

00:18.620 --> 00:20.210
Go over to your table.

00:20.420 --> 00:23.420
You got a table if you want but that is no problem.

00:23.420 --> 00:28.310
And on a database go down here you can see we'll have what is called views.

00:28.340 --> 00:29.450
Views.

00:29.450 --> 00:32.180
So these views are very important.

00:32.450 --> 00:33.440
Yes.

00:33.440 --> 00:35.480
What is the use of views in MySQL.

00:35.510 --> 00:36.890
That is very crucial you ask me.

00:36.890 --> 00:40.880
So views are virtual tables like we create these tables right in here.

00:40.910 --> 00:47.150
We can create a mural or a virtual table and a mirror or everything we have right in here.

00:47.150 --> 00:54.170
So this table will have employee table or distress table everything to computer that's right in here.

00:54.170 --> 01:01.020
And any changes we do in this table or in table or any of our table here will we actually reflect on

01:01.020 --> 01:03.780
the view table without touching the view table.

01:04.020 --> 01:04.980
Yes.

01:05.220 --> 01:07.650
Now let me go ahead and say give an example of how this works.

01:07.650 --> 01:14.910
So you have a stress table and someone comes in or actually comes in and says I need a stress attendance.

01:15.420 --> 01:20.280
And you are not going to add that right in here because the attendance might always change.

01:20.280 --> 01:22.800
And, uh, what are you going to do?

01:22.830 --> 01:24.900
You don't need to create other stress table.

01:25.020 --> 01:29.550
All you need to do is to mirror this stress table into the views table.

01:29.550 --> 01:32.640
And that creates what is called a students attendance.

01:32.640 --> 01:34.920
And that is going to be under the views table.

01:34.920 --> 01:40.320
So you can actually drop that attendance list for that particular uh lecture.

01:40.320 --> 01:43.920
And another lecturer comes, you create another attendance list.

01:43.950 --> 01:46.050
So without altering your students table.

01:46.050 --> 01:49.230
So in that way the student is always saved.

01:49.260 --> 01:56.310
But whatever we do in the stress table, we actually reflect on our attendance table which is under

01:56.310 --> 01:57.270
the views.

01:57.450 --> 02:03.400
So the views are not real, but they can we can interact with them from the real tables.

02:03.430 --> 02:09.310
Now let's go ahead and create a student attendance table and see that how it works.

02:10.120 --> 02:13.870
So let me go ahead and say I'm going to create view.

02:13.870 --> 02:21.550
And then I'm going to name my view to be students underscore attendance.

02:21.940 --> 02:22.480
All right.

02:22.480 --> 02:33.190
So our underscore attendance as then you go ahead and select the score here and select the first name

02:33.190 --> 02:35.650
of our students and the last names right.

02:35.680 --> 02:44.200
So we're going to say first underscore name and our last underscore name.

02:44.350 --> 02:46.420
And where are you selecting these.

02:46.420 --> 02:48.970
You're going to select that from a table.

02:48.970 --> 02:52.630
So you go ahead and choose a table I'm selecting that from my students table.

02:52.630 --> 02:55.690
So I'll go ahead and say from students.

02:55.690 --> 03:01.790
And the place is semicolon now because I create what is called view with this keyword view.

03:01.820 --> 03:05.990
It means I'm creating a table from a student's table.

03:06.020 --> 03:09.080
Because you selected I'm going to create this from the students table.

03:09.110 --> 03:14.390
So you can actually select maybe from the employees table, from subjects or from teachers depending

03:14.390 --> 03:15.680
on whatever you want to do.

03:15.710 --> 03:17.990
But here I want to take student's attendance.

03:18.020 --> 03:20.600
I want to take the attendance based on the students table.

03:20.630 --> 03:23.510
We just want to mirror this on their views.

03:23.510 --> 03:29.840
So I'm going to work with it and maybe present that with our students table.

03:29.870 --> 03:32.660
Go ahead and execute this query and check it out.

03:32.690 --> 03:36.080
Now with this go ahead and refresh this and check it out.

03:36.470 --> 03:37.940
Now what's your views.

03:37.940 --> 03:43.430
You can see we have what is called students attendance and the attendance.

03:43.430 --> 03:45.500
You can see first name and last name.

03:46.160 --> 03:47.810
Wow that is cool.

03:48.560 --> 03:48.800
All right.

03:48.800 --> 03:52.460
Now let's go ahead and check out our students attendance table.

03:52.490 --> 04:00.650
Go ahead and select all From strains on the squash tendons and semicolon at the end.

04:00.650 --> 04:02.690
And go ahead and execute the query.

04:02.690 --> 04:09.590
And you can see that now we are selecting what is called students attendance and not student attendance.

04:09.650 --> 04:11.030
I must do this alone.

04:11.150 --> 04:15.380
So we have a table called attendance and that is under the views table.

04:15.380 --> 04:21.320
So from here you can present everything or this attendance list to anybody that requested that.

04:21.350 --> 04:23.720
We talked about your students table.

04:23.720 --> 04:29.330
And you can actually go ahead and interact with your student attendance table by using some keywords

04:29.720 --> 04:30.980
in the previous lectures.

04:31.010 --> 04:37.280
Let me go ahead and say I want to order these by alphabetical, just like we do or done by.

04:37.310 --> 04:39.980
Go ahead and see order by.

04:39.980 --> 04:41.600
And let me see.

04:41.960 --> 04:44.960
Um, last underscore name.

04:45.680 --> 04:49.220
And then why not put semicolon at the end.

04:49.370 --> 04:49.820
Okay.

04:49.850 --> 04:54.320
You can actually make this to be maybe ascending order or anywhere.

04:54.350 --> 04:56.340
Maybe be ascending or descending order.

04:56.580 --> 05:02.850
So if we do that, you can actually go ahead and uh, say order is not a valid keyword.

05:03.840 --> 05:06.720
Oh, so this is our AC.

05:07.080 --> 05:07.800
Okay.

05:08.070 --> 05:09.420
And that is all.

05:10.020 --> 05:10.470
Okay.

05:10.470 --> 05:11.940
So I have an order by this.

05:11.970 --> 05:14.250
So all I need to do is that I'm going to select this.

05:14.250 --> 05:16.050
So I replace this.

05:16.050 --> 05:17.520
So go ahead and place this under here.

05:17.550 --> 05:21.120
So what happens is I'm going to select all from students attendance.

05:21.120 --> 05:22.740
Then order it by the last name.

05:22.770 --> 05:23.820
That is what I wanted to do.

05:23.820 --> 05:27.150
And I was putting that above that and execute this query.

05:27.150 --> 05:28.080
Let's check it out.

05:28.110 --> 05:33.750
Now you can see order by last name and by ascending order.

05:34.020 --> 05:39.090
All you can see here is Harry, Joel, Rocky, Sam and smart.

05:39.180 --> 05:39.660
All right.

05:39.690 --> 05:41.190
Now that is by the last name.

05:41.190 --> 05:42.870
So you can actually do that by first name.

05:42.870 --> 05:48.420
Go ahead and say first underscore name and go ahead and check it out.

05:48.420 --> 05:52.020
Barak, Mike, Oscar, Peter, Quinn, Sarah and Zendaya.

05:52.110 --> 05:54.740
So you can actually interact with all these.

05:54.740 --> 05:58.880
And you can also drop your, uh, views table.

05:59.000 --> 05:59.480
All right.

05:59.480 --> 06:03.980
Let me go ahead and show you how to drop the views table so we can actually, um, see how it works.

06:03.980 --> 06:08.750
So after I interact with the table and everything you need, you can actually go ahead and say, I want

06:08.750 --> 06:10.310
to drop the view table.

06:10.580 --> 06:12.830
Let's say drop a view.

06:12.830 --> 06:20.630
And you name your view table as a student's attendance and semicolon at the end and as a previous query.

06:20.630 --> 06:22.370
And now go back here.

06:22.370 --> 06:23.810
You can also refresh.

06:23.840 --> 06:26.960
You can see that the view table is no longer there.

06:27.620 --> 06:27.860
All right.

06:27.860 --> 06:28.850
So this is about a table.

06:28.880 --> 06:31.040
I'll give you one more example in the next video lecture.

06:31.040 --> 06:33.440
So let's go over to the next lecture and do one more example.

06:33.440 --> 06:34.430
That is very interesting.

06:34.430 --> 06:40.400
So see in the next lecture we will go ahead and share more on the views and MySQL and uh hope to catch

06:40.400 --> 06:40.940
you there.

06:41.000 --> 06:42.980
Thank you and see you in the next video.
