I will call them back again to one another within my circle.
And in this video lecture we will go ahead and learn about soft query in MySQL.
So in MySQL we have a subquery and it will be like what is soft query.
So soft query is a query inside another query.
Everything is about query in MySQL.
Yes everything is about query.
Now let's go ahead and say we have this table or students table in here.
And we have the students GPA.
And you can see the GPA of 3.5 to 4 point 7 to 2.7, 4.8 to 0 point 9 to 2.8 and 1.0.
So once you get the average of this GPA.
Let's go ahead and select.
And I'm going to say select uh avg.
So I can go ahead and pass in this table name GPA right in there I'll go ahead and say GPA.
And then I'll go ahead and uh say from this table and the name of this table is students.
And go ahead and execute this query.
And you can see Avg and that is 3.49.
All right.
So 3.49 or 3.4857143.
All right.
That is cool.
You can go ahead and make this to uppercase SVG and go ahead and execute the query.
And that is what we have.
So I'll be using the uppercase to do this.
And let's go ahead and create a sub query from this.
Okay.
Let's go ahead and make this a subquery inside another query in this table.
So let me go ahead and select all the first name and last name of students who have their GPA and a
warhead and say select.
And I'll go ahead and say select underscore first name and I will select underscore last name.
And I'll select the GPA and the comma.
So I'll go ahead and pass in the uh the average of this GPA from the students.
So pass out from two To Strange Table, and I forgot that these activities would go ahead and get a
first name, the last name and a GP and the average of this GP last year.
So you can see select from GP avg is too big.
So we have to make this an alias.
And that's why I shorten the name so that it can doesn't look good.
All right.
So if I'm choosing the name, what I need to do is to go ahead and say as semicordata be avg.
So avg underscore GP I hope that is cool.
And if we run this again so I can query and have the average of each of these GP, is this.
So the average of each of today's GP is 3.49.
So I hope that's cool.
So we can now find the students whose GPAs are above the average.
So how can you be able to find students whose GPA is above the average.
So you can see how we are using the query inside another query.
And we are still going to use this right here.
So how can we do that.
Now let's go ahead and say we select all first name and last name and GP from students.
Go ahead and select that from violence from students.
And uh, we say students.
And then I'll go ahead and remove this from here and put this.
And I'm going to say I'm selecting this from students.
We are using the Where clause where the IGP is greater than the average of this GP.
So remember that this is just average of this GP.
All right.
So we're going to put a semicolon at the end of this.
And we still have our an arrow here.
Or I need to just go ahead and remove this comma here.
And it says select all from students.
The first name last name from students where the GP is this.
So I can go ahead and remove this here and I'll go ahead and run this.
Let's check it out.
And these are the students whose GP are above the average because the average of the GP is 3.49, and
you can see we have our 3.5, 4.7, 3.7, 4.80 and 3.8.
All right.
So these are the students whose uh GP are above the average of the GP, which we have in the previous
table we created or with the previous query we just executed.
All right.
So from the average we are able to get the students who they are GPS are above average and that looks
good.
So put this down practice with it.
And uh I hope from here you can understand what we're doing.
And, uh, in the next lecture, we'll go ahead and tackle the example and see how it works.
So let's take it one step at a time.
Check out this.
And if you have any questions on this or how to use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.