Welcome back.
So in this section, we're going to focus on what are called logical operators.
Actually, we're focusing on operators in general, and most of the ones we're going to work with are
logical operators.
That distinction doesn't really matter, though.
I'm just going to call them all logical operators, and they allow us to add logic into our SQL statements.
So up until this point, we've seen things like well, like, like which allows us to select things
based off of text looking or containing certain strings, matching patterns.
We've seen how to do things where we can check, select all books where the title is exactly Lincoln
in the Bardo or where released year is exactly 2013.
But there's a whole slew of other things that we'd like to be able to select based off of, and that's
what we're going to focus on in this section.
So we're going to see how to do things like select all books not published in 2017.
Right now, we don't have a way of doing that.
Or what about select all birthdays between two different dates?
So not just all birthdays that are exactly, you know, April 22nd, 1990 or 1992 or whatever it is,
but between those two dates.
Or select all items.
So this is some table I made up called items, all items that are in stock and price below 1999.
So that's two different things.
We know how to select all items that are in stock, but there is a second component, which is not only
do they need to be in stock, but they need to be priced below 1999.
And right now we don't know how to do that either.
With that lengthy introduction out of the way, let's take a look at some of our first ones.
So the actual first one we're going to look at is called not equal.
And it looks like this exclamation point and an equal sign.
So we've seen how to do things using equal sign, right?
We've done select.
Let's do title comma released here from books where and let's do release here.
So we're released here is exactly 2017.
So we've seen how to do this with equal sign.
We've been doing it all the time.
However, what if I want to do the opposite?
I want all books that were released in any year, excluding 2017.
So what we want to do is basically replace that equal sign with a not equals.
So we could do this select title from books where year is not equal to 2017.
If you're familiar with any programming languages, you've probably come across this not equals.
It's a pretty universal way of of writing, not equals.
So let's give it a shot.
Recall this and just replace it with not equals.
And now you can hopefully see that we get everything back except for Lincoln in the Bardo.
And of course, if there was more than one book released in 2017, then we would get any book back or
all books back.
Except that those books from 2017.
So we can see that it's gone.
We could do the same thing.
But instead of working with Release Year, what if we do it with author?
So let me just start over here.
Let's select title and author last name from books and we'll start just with all of them.
And then let's select where the last name is exactly equal to Harris.
So we have those two Harris's.
Where.
Author ll name equals Harris.
Just like that.
And we get those, too.
And by just flipping the switch here, that exclamation point.
We now get everything except those two, so hopefully you get the point by now.
Not equals works like you would expect.
If you're not familiar with the exclamation point, it might take a little bit of getting used to,
but otherwise it's pretty straightforward.
It's the opposite of equals.
Awesome.
So that's the first one that we're taking a look at, but we have quite a few more.
Next up, we're going to talk about something very similar, which is not like.