I will call you back again to another video lecture in MySQL.
And in this lecture, let's go ahead and look at the limit clause in MySQL.
All right.
So let's go ahead.
And now look at a clause known as the limit clause.
And this is used to limit the number of records in MySQL for people working with a large amount of data.
So this can be used to display large data on pages.
And these pages are known as pagination.
Let's go ahead and see from a table the students table below.
Let's go ahead and select all from students.
And then we go ahead and limit that.
That's why I say limit.
You can see that limit is a keyword.
And first of all I will limit that to just one.
All right.
And as it kills this let's see what happens.
So it goes on to get in just one of the very first one.
So imagine you want to check out maybe the second, the third, the fourth.
And you just want to get only one.
So if you go ahead and check two we will go to public.
Two go ahead and check it out.
We have two records shown.
So in that case if we also do three, you go ahead and get three records shown.
And in that way if you also do four, you get four records shown and so on till the last one.
And that is it.
So this is about limit uh, class.
And um, you can combine the limit class with the order by clause in a way to do that the score head
and say we want to combine that.
I'll go ahead and say the order by, and then we can select maybe the first name or the last name or
department or GP or a road date.
Let's go ahead and select the first underscore name.
And then we're going to limit that by just maybe three.
And let's go ahead and check it out.
So we selected that and it populates based on the ascending order.
That is why it is not arranged.
So looking at the student's ID and by order you can see that one would discuss order previously.
It's always start by the ascending order that is the default.
So if you want that to be maybe by descending order, what you need to do is order by first name.
Then you go ahead and say the same and then limit three and go ahead and check it out.
So it starts from the descending order.
So you can also increase this to like four or any number just like we did.
And you can see that.
So you can use the order by clause which are in conjunction with the limit clause.
So with limit clause you can also add an offset.
Let's go ahead and say I'm going to remove this.
And then I'll go ahead and remove this.
I'm going to say limit.
And then I'll go ahead and put the offsets.
Maybe I want to start from anyone.
I'm going to say start from the very first one and display just one.
And then it goes on to do this.
Remember that based on the previous one, that is what is still showing.
Go ahead and remove this and let's select Add Table.
And this is our table.
So I'll go ahead and bring back the limits cross again.
So go ahead and say limit.
Then the offset is going to start from let me say starts from three.
That means we want to display barracks and then we want just to be displayed only one.
Then go ahead and show this.
All right.
So the uh the limit start from zero index.
And that is why it moves to the first one.
So I want to display barracks.
I'll go back I change this to two and barrack is shown.
So the very first one is index zero.
So if I go ahead and start from zero it's going to display to as a very first one.
You see that display limit starts from zero.
And now if we want to display like maybe two.
Go ahead and add two and go ahead and display from Peta and then move to Oscar.
That is it.
So I want to start maybe from four.
I showed two numbers.
Only two of the data.
All right.
Go ahead and execute the query.
And I have Mike and Queen.
So you can also increase the move your offsets.
So the very first one here is offset.
Okay.
So go ahead and check it out.
So offset is the very first one.
And then the limit is the second one.
So the second condition is the limit while the first condition is the offset where you're going to start.
So go ahead and check out these and you can set another WhatsApp file is very interesting.
So play around with it.
And if you have any question go ahead and use the question 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.