Next up, we're going to talk about some logical operators that are built into MySQL that help us write
more complex queries and more complicated logic.
For example, a simple thing that we could do by the end of this section is select all the books not
published in 2017.
We know how to publish or select books published in 2017, but what about the opposite?
Or select all birthdays between 1990 and 1992?
Or select all the items that are in stock and also have a price under 1999.
So these are still relatively simple, but there's building blocks that we're going to cover things
like not and between and and so we'll get there.
We're going to start in this video with not equal.
So an exclamation point in front of the equal sign means not equal.
In this example, I'm selecting the title from books where the year is not 2017.
So of course we know how to do select star from books where I think it's released year is equal to what
did I say, 2017.
There we go.
Lincoln in the Bardo 2017.
There's one book Row 19 But if I put an exclamation point in front of that equal sign, that now means
not equal.
So we'll select any books where release year is anything but 2017.
So we get a bunch of them, as you can see here, but we won't have 2017, so we're missing that row.
It might be a little harder to tell, but why don't we try another example?
Let's select title and author, last name from books, and let's select all the books that were not
written by Gaiman, Neil Gaiman.
So we'll just use the last name.
So I would do something like select title and author, last name from books where author L name.
And instead of saying it's equal to Gaiman, of course that's going to give me Neil Gaiman's three books.
Oh, I spelled it wrong, gay man like that.
GAIMAN Instead of that, we're going to just put an exclamation point to invert the meaning of this.
Now, again, author last name can be anything except Neil Gaiman or just Gaiman.
And we see all of the books, minus the Gaiman books.
So there's a smaller group.
You still just have to kind of trust that it works, but you can see there's no Gaiman here versus here.
You know, we had Gaiman, Gaiman and Gaiman there.
So that's our first example of a logical operator.
We've actually already seen a quality which is a logical operator as well, the single equal sign.
But when we put that bang in front of it or the exclamation point, it means not equal.
So next step, we're going to keep learning some more of these operators.