1
00:00:00,240 --> 00:00:04,230
The next operator will look at is a comparison operator called between.

2
00:00:04,230 --> 00:00:09,070
But before we look at it, I want to take a look at what we can do without it.

3
00:00:09,090 --> 00:00:15,150
We can accomplish the same thing that between helps us do, which is to narrow down values that are

4
00:00:15,150 --> 00:00:21,420
between, let's say, five and 20 or between a lower threshold and an upper threshold, but we can actually

5
00:00:21,420 --> 00:00:21,990
do that.

6
00:00:21,990 --> 00:00:24,150
So how could we accomplish this with what we know?

7
00:00:24,150 --> 00:00:30,180
How could we do something like select all the books published between 2004 and 2015?

8
00:00:31,030 --> 00:00:32,220
Think about it for a moment.

9
00:00:32,229 --> 00:00:36,810
There's really two different pieces of comparisons here, Right.

10
00:00:36,850 --> 00:00:38,470
We're going to look at release date.

11
00:00:39,390 --> 00:00:45,660
And somehow compare it to 2014 and compare release date to 2015.

12
00:00:46,560 --> 00:00:49,260
So it would look something like this.

13
00:00:49,770 --> 00:00:55,530
We'll select the title and the release year, whatever we want from books where the release here is

14
00:00:55,530 --> 00:00:59,850
greater than and equal to greater than or equal to 2014.

15
00:01:00,150 --> 00:01:05,670
And at the same time, release year is less than or equal to 2015.

16
00:01:05,880 --> 00:01:10,650
And that would give us the books published between those years.

17
00:01:10,680 --> 00:01:15,810
Assuming I want to include 2004 and 2015, then I use the equal sign.

18
00:01:16,230 --> 00:01:18,390
So let's try that just real quick.

19
00:01:19,170 --> 00:01:24,510
Let's select the title released year from books.

20
00:01:24,870 --> 00:01:31,200
And then the first piece will be Either way, we can say where books are, where release year is greater

21
00:01:31,200 --> 00:01:32,320
than 2004.

22
00:01:32,340 --> 00:01:39,750
Or we could go the other way and say where release year is less than or equal 2015.

23
00:01:40,170 --> 00:01:46,560
And at the same time, released year is also greater than or equal to 2004.

24
00:01:48,690 --> 00:01:49,530
We run it.

25
00:01:49,530 --> 00:01:53,130
And all these books are released between 2004 and 2015.

26
00:01:53,130 --> 00:01:57,180
So for five we got 2010, 12, 13 and 14.

27
00:01:57,720 --> 00:01:58,350
Great.

28
00:01:58,350 --> 00:01:59,520
So that is valid.

29
00:01:59,520 --> 00:02:04,020
We don't need this between operator but between makes it cleaner.

30
00:02:04,020 --> 00:02:05,250
It's a lot shorter.

31
00:02:05,250 --> 00:02:12,150
We can instead select books where released year between 2004 and 2015.

32
00:02:12,150 --> 00:02:16,920
We don't have to use an and well, we actually do use an ad, but we don't have to use an end to join

33
00:02:16,920 --> 00:02:17,670
together.

34
00:02:17,970 --> 00:02:19,920
Two different comparisons, right?

35
00:02:19,920 --> 00:02:22,110
We don't have to do less than equal to greater than or equal to.

36
00:02:22,140 --> 00:02:32,160
It's as simple as select title released year or whatever we want from books where released year between

37
00:02:32,370 --> 00:02:37,320
and then whatever values we want in 2004 and 2015.

38
00:02:39,310 --> 00:02:40,710
And we should get the exact same.

39
00:02:40,720 --> 00:02:43,570
Oh, what did I missing in SE on books?

40
00:02:44,110 --> 00:02:45,280
All right, try that again.

41
00:02:46,330 --> 00:02:48,580
And we should get the same exact results.

42
00:02:48,910 --> 00:02:50,550
You'll see it is inclusive.

43
00:02:50,560 --> 00:02:52,180
So we see 2004.

44
00:02:52,450 --> 00:02:58,690
Now, we don't have any books released in 2015, but let's say I changed it to 2014 just so that we

45
00:02:58,690 --> 00:02:59,770
can prove this.

46
00:03:00,010 --> 00:03:02,110
We still get 2014 books.

47
00:03:02,110 --> 00:03:08,710
So 20 or 2004 is included and 2014 it's inclusive on both sides of the range, right?

48
00:03:08,710 --> 00:03:11,980
The low end and the upper side or the high end.

49
00:03:12,220 --> 00:03:13,420
Let's try one more example.

50
00:03:13,420 --> 00:03:19,720
Let's select the books that are, I don't know, between 203 hundred pages.

51
00:03:20,470 --> 00:03:32,800
So select let's just do title and pages from books where pages is between and then 203 hundred.

52
00:03:33,740 --> 00:03:34,670
And there we are.

53
00:03:34,700 --> 00:03:38,050
These books, The Namesake, Coraline, Gosh, love Coraline.

54
00:03:38,060 --> 00:03:39,020
Great movie.

55
00:03:39,110 --> 00:03:40,790
See that adaptation if you haven't seen it?

56
00:03:40,790 --> 00:03:42,110
And 10% happier.

57
00:03:42,740 --> 00:03:45,980
I've not read that book, but I needed one that had a percent sign in it.

58
00:03:46,010 --> 00:03:48,890
They all are between 203 hundred pages.

59
00:03:49,010 --> 00:03:50,270
So that's between.

60
00:03:50,270 --> 00:03:57,740
But we also have not between, which is just it's the same sort of deal as like and not like it is going

61
00:03:57,740 --> 00:04:04,790
to be not space between and then the same thing afterwards, whatever, whatever that range is we want

62
00:04:04,790 --> 00:04:06,170
to exclude.

63
00:04:06,740 --> 00:04:13,370
So I could find all of the books where their pages are not between 203 hundred that will give me all

64
00:04:13,370 --> 00:04:17,600
the books that are less than 200 and greater than 300 pages.

65
00:04:17,779 --> 00:04:21,950
So we see 176, we see 198.

66
00:04:21,950 --> 00:04:23,870
Those are all less than 200.

67
00:04:24,260 --> 00:04:30,860
But then we also see three 2428, 634, everything greater than 300.

68
00:04:31,100 --> 00:04:36,410
But we don't see any of the books that we had before between two and 300.

69
00:04:36,740 --> 00:04:37,920
So that's not between.

70
00:04:37,940 --> 00:04:43,160
Just remember, we use not space between and the order doesn't matter.

71
00:04:43,160 --> 00:04:47,720
And then our numbers on the low end and number on the high end.

