Hello, in this video, we are going to cover a limiting data selection. So what do I mean by that? So we've got this little application that just basically selects all of the data from the users table. She's four rows at the moment and displays it. Imagine if you had thousand rolls in there. And you maybe it's a bunch of comments, like on a social networking website, usually don't have all comments loaded up straight away, who usually have let's say, 10, they scroll to the bottom or click a button to load the next and then the next and the next 10.
So limiting allows you to basically say I only want this many. So the first way that we can do it is by putting a keyword limit and this will just mean I want this many so if I put two, it will just give me these two. It will just give me the first two obviously if the the where condition, you can put that afterwards as well. But the limit will just apply to the ones that are successfully you know passing the where condition. So, this is one way of doing it a normal way of limiting is using the top command. So, using the top command is actually basically the same but I want to show you just in case you see online somewhere for example, so if I say talk to we work in Okay, ignore that one, then I think they've taken that out in the version of SQL, they're immune.
So you can you can just use the limit. The other one that you can use is row num. So row num, so remember if we have, you know, where, and we could say where let's say ID equals three foot and where ID equals three, your return basically just that one, but we can also say where Ronen for where so ID is less than or equal to three, and that will return all the ones are all less than or equal to free. So that's a you know, a bit more flexible than just saying is equal to A specific one. And what you can also do is I want to see if this actually works, because one second, the top didn't work. This will be interesting if this one works to another one for percentage, but let me just type it in and see if it works.
That I have updated my SQL recently. So you could have, you know, been, you know, not being the light, right? And if it didn't, it didn't matter. Who is a top 15? Rhonda? Nope.
Yes, that's no longer in the so we can get rid of that. So yeah, the two ways of really limiting is doing this way. So like basically checking the row number and you know, and so range, and also using a limit, we just get the first X number of rows. So that's how you limit data selections. If you have any questions, feel free to pop me a message. And as usual, I look for to seeing you in the next video