All right.
So we're moving on to logical or which, as I just mentioned, is like the brother or sister to logical.
And and if you've worked with any programming language you're most likely familiar with and and or logical
and and logical or so logical or you can either write out as or or just like we could write a and for
and or we can use these to pipe symbols.
So these are not uppercase I's or L's or ones.
They are the pipe character which is usually located above the right return or enter key.
You have to hit shift most often to hit it.
So it's two of them together, just like it was to Ampersand four.
And it's just symbols.
It's pretty standard.
Rights are very standardized across all programming languages that I've worked in ampersand for and
pipes for or but you can also use the phonetic or the spelled out version or so.
Before we dive into exactly how it works, let's try something.
So we had this in the last video.
This selects all books written by Dave Eggers, released after the year 2010.
But what if we just change the ampersand to the or pipes?
What do you think will happen, first of all?
So I'm just going to copy this so we don't have to type this all again.
And just change the ampersand here to or and I'll make I'll hit return so it's clearer what's happening.
So if we read this, if you just say the word or here it makes a bit more sense.
Select title and author name and release here from books where author name is Eggers or released your
is greater than 2010.
So if we run it, what we'll get is all books written by Dave Eggers and all books where a release year
is greater than 2010.
So rather than both sides of this having to be true, just if either side is true, we'll get the data.
So we get all the books by Eggers, including this one.
Our heartbreaking work is Staggering Genius, which came before 2010.
But then we move on to the second part, which MySQL selected all books that were released after 2010,
regardless of the author name.
So it's a way for us to specify two things, either of which we want to be true or both.
So in the case of a hologram for the King, it is both written by Dave Eggers, and it was released
after 2010.
Or same thing with the circle here.
But 10% happier, for instance, was only this part was true.
Released year is greater than 2010 because author L name is Harris or Saunders in this case or Gaiman.
So again, that symbol right there, I forgot I made this nice little slide with this animation that
change a symbol is very, very important.
It changes the meaning entirely from the statement.
Okay.
So if we have two conditions with an ampersand between them or three or any number of conditions with
ampersand, it means that both sides must be true in order for the whole thing to be true, as we've
seen already.
However, with the OR operator, it means only one side must be true for the whole thing to be true,
or both sides can be true as well.
And I know that's a bit odd to talk about in this way without actual examples.
So if we hop over again, I'm going to do the same thing I've been doing the last couple of videos.
I'm going to type up a few example exercises and then we'll go over solutions.
Okay, so I'm back here.
I've got three, just three this time that I'll use logical or so try them out and then I'll be right
back with a solution and I'm back already.
Okay, so first one here.
40 less than or equal to 100.
Well, that part's true.
40 is less than 100.
So it doesn't matter what's over here.
This whole thing is true because we only need one half to be true.
It happens that negative two is not greater than zero, but that's irrelevant because the left side
is true.
Moving on to this one, ten greater than five, is that true?
Yes.
So it doesn't matter what's on the right side, but that happens to also be true.
So the whole thing is true.
So we get one and this last one, a bit of a curveball.
Is the letter a equal to the number five?
Well, that's not true.
However, this side says 3000 is greater than 2000.
That is true.
So the whole thing is true.
As you can see, we get one for true.
Last thing before I forget just like with and we can chain or together as many times as we want so it
doesn't have to be something like this.
So if I go back to this example, select title, author l name or here from books where author name
is Eggers or released year is greater than 2010.
So let's try adding an OR here and I'll spell it out this time.
And let's say not only do we care or do we want to select things written by Eggers or released year
greater than 2010, we'll also add another or which is stock quantity is greater than 100 so books that
we have a lot of stock in as well.
And let's also print stock quantity just like that.
Just copy this whole thing, paste it semicolon.
And if we look see it makes a slight difference because we also get this David Foster Wallace story
collection in here, which is written in 2004, which normally wouldn't make the cut with our previous
version, but because we added stock quantity greater than 100, it's in here because stock quantity
is greater than 172.
So for some of these, for instance, a hologram for the King, all three parts are true.
It's written by Eggers.
It's released after 2010, and it has more than 100 copies in stock.
But then, like for David Foster Wallace and Oblivion, only one part is true.
The last part.
So just goes to show you that only one component, even if we have three different conditions, only
one part has to be true for the entire thing to be true and for it to be selected and spit back to us.
Okay.
So that's logical.
Or one thing that I will point out that I know you're probably dying to get on with this video, but
you can combine or and end and we'll see how to do that in a little bit.