WEBVTT

1
00:00:00.120 --> 00:00:01.440
<v Jose>Hi guys and welcome back.</v>

2
00:00:01.440 --> 00:00:03.040
In this video we're going to learn about

3
00:00:03.040 --> 00:00:06.560
limiting the number of results we get back when selecting

4
00:00:06.560 --> 00:00:08.360
using the limit keyword.

5
00:00:08.360 --> 00:00:11.840
We can get, for example, the 10 most experienced employees

6
00:00:11.840 --> 00:00:15.310
using order by and limit as in this example.

7
00:00:15.310 --> 00:00:16.900
Select star from employees;

8
00:00:16.900 --> 00:00:19.470
order by years experience in descending order

9
00:00:19.470 --> 00:00:21.450
so the highest ones are at the top;

10
00:00:21.450 --> 00:00:25.890
limit 10 just gives us 10 rows or up to 10 rows.

11
00:00:25.890 --> 00:00:29.070
If there's fewer than 10 rows then we will get that number.

12
00:00:29.070 --> 00:00:31.840
Without the order by it's not so useful.

13
00:00:31.840 --> 00:00:33.490
You can just get the 10 first rows

14
00:00:33.490 --> 00:00:36.410
that were added to table matching the constraint.

15
00:00:36.410 --> 00:00:39.060
So here, you're getting select star from employees;

16
00:00:39.060 --> 00:00:42.240
where the salary is greater than 100,000; limit 10.

17
00:00:42.240 --> 00:00:43.840
You're just getting the 10 first employees

18
00:00:43.840 --> 00:00:46.770
that were added to the table with that salary.

19
00:00:46.770 --> 00:00:48.620
Or just the first 10 rows

20
00:00:48.620 --> 00:00:50.480
if you don't include a where clause at all.

21
00:00:50.480 --> 00:00:52.210
Pretty useless in most cases.

22
00:00:52.210 --> 00:00:54.190
Select star from employees limit 10,

23
00:00:54.190 --> 00:00:55.640
just gonna give you the first 10 rows

24
00:00:55.640 --> 00:00:57.300
added to the table, period.

25
00:00:57.300 --> 00:01:00.040
The limit keyword pretty easy to use as you can see.

26
00:01:00.040 --> 00:01:02.390
Just gives you up to a number of rows.

27
00:01:02.390 --> 00:01:03.820
Thank you guys for watching this video,

28
00:01:03.820 --> 00:01:05.493
I'll see you in the next one.

