The next operator will look at is a comparison operator called between.
But before we look at it, I want to take a look at what we can do without it.
We can accomplish the same thing that between helps us do, which is to narrow down values that are
between, let's say, five and 20 or between a lower threshold and an upper threshold, but we can actually
do that.
So how could we accomplish this with what we know?
How could we do something like select all the books published between 2004 and 2015?
Think about it for a moment.
There's really two different pieces of comparisons here, Right.
We're going to look at release date.
And somehow compare it to 2014 and compare release date to 2015.
So it would look something like this.
We'll select the title and the release year, whatever we want from books where the release here is
greater than and equal to greater than or equal to 2014.
And at the same time, release year is less than or equal to 2015.
And that would give us the books published between those years.
Assuming I want to include 2004 and 2015, then I use the equal sign.
So let's try that just real quick.
Let's select the title released year from books.
And then the first piece will be Either way, we can say where books are, where release year is greater
than 2004.
Or we could go the other way and say where release year is less than or equal 2015.
And at the same time, released year is also greater than or equal to 2004.
We run it.
And all these books are released between 2004 and 2015.
So for five we got 2010, 12, 13 and 14.
Great.
So that is valid.
We don't need this between operator but between makes it cleaner.
It's a lot shorter.
We can instead select books where released year between 2004 and 2015.
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
together.
Two different comparisons, right?
We don't have to do less than equal to greater than or equal to.
It's as simple as select title released year or whatever we want from books where released year between
and then whatever values we want in 2004 and 2015.
And we should get the exact same.
Oh, what did I missing in SE on books?
All right, try that again.
And we should get the same exact results.
You'll see it is inclusive.
So we see 2004.
Now, we don't have any books released in 2015, but let's say I changed it to 2014 just so that we
can prove this.
We still get 2014 books.
So 20 or 2004 is included and 2014 it's inclusive on both sides of the range, right?
The low end and the upper side or the high end.
Let's try one more example.
Let's select the books that are, I don't know, between 203 hundred pages.
So select let's just do title and pages from books where pages is between and then 203 hundred.
And there we are.
These books, The Namesake, Coraline, Gosh, love Coraline.
Great movie.
See that adaptation if you haven't seen it?
And 10% happier.
I've not read that book, but I needed one that had a percent sign in it.
They all are between 203 hundred pages.
So that's between.
But we also have not between, which is just it's the same sort of deal as like and not like it is going
to be not space between and then the same thing afterwards, whatever, whatever that range is we want
to exclude.
So I could find all of the books where their pages are not between 203 hundred that will give me all
the books that are less than 200 and greater than 300 pages.
So we see 176, we see 198.
Those are all less than 200.
But then we also see three 2428, 634, everything greater than 300.
But we don't see any of the books that we had before between two and 300.
So that's not between.
Just remember, we use not space between and the order doesn't matter.
And then our numbers on the low end and number on the high end.