WEBVTT

00:00.150 --> 00:00.840
All right.

00:00.900 --> 00:07.320
So we're moving onto logical order which as I just mentioned is like a brother or sister to a logical

00:07.350 --> 00:07.850
end.

00:07.980 --> 00:14.820
And if you've worked with any programming language you're most likely familiar with and and or logical

00:14.820 --> 00:21.420
and and logical or so logical or you can either write out as Omar or just like we could write A&amp;E for

00:21.420 --> 00:24.880
and or we can use these two pipe symbols.

00:24.960 --> 00:32.040
So these are not uppercase eyes or els or ones they are the piped character which is usually located

00:32.250 --> 00:35.090
above the right return or enter key.

00:35.100 --> 00:38.420
You have to hit shift most often to hit it.

00:38.550 --> 00:44.190
So it's two of them together just like it was two ampersands for and just symbols.

00:44.190 --> 00:49.780
It's pretty standardized or very standardized across all program languages that I've worked in ampersands

00:49.860 --> 00:51.630
and types for or.

00:51.810 --> 00:56.180
But you can also use the phonetic or that spelt that version o r.

00:56.340 --> 01:00.690
So before we dive into exactly how it works let's try something.

01:00.690 --> 01:02.610
So we had this in the last video.

01:02.670 --> 01:05.310
So it's all books written by Dave Eggers.

01:05.460 --> 01:07.780
Released after the year 2010.

01:08.280 --> 01:13.750
But what if we just change the ampersands to the or pipes.

01:13.950 --> 01:15.470
What do you think will happen first of all.

01:15.480 --> 01:19.590
So I'm just going to copy this an Oxford type this all again.

01:21.730 --> 01:28.150
And just change the ampersands here to OR and make a hit return.

01:28.150 --> 01:30.820
So it's clear what's happening.

01:30.820 --> 01:36.640
So if we read this if you just say the word or hear it makes a bit more sense it's like title An author

01:36.640 --> 01:44.240
name and released year from books where author name is Aggers or released here is greater than 2010.

01:45.310 --> 01:55.090
So if we run it what we'll get is all books written by Dave Eggers and all books were released here

01:55.240 --> 01:56.780
is greater than 2010.

01:57.220 --> 02:03.220
So rather than both sides of this having to be true just if either side is true we'll get the data so

02:03.220 --> 02:09.640
we get all the books by Eggers including this one a heartbreaking work a staggering genius which came

02:09.640 --> 02:17.200
before 2010 but then we move on to the second part which is to selected all books that were released

02:17.230 --> 02:20.440
after 2010 regardless of the author's name.

02:20.950 --> 02:25.810
So it's a way for us to specify two things either of which we want to be true or both.

02:25.960 --> 02:32.680
So in the case of a hologram for the king it is both written by Dave Eggers and it was released after

02:32.800 --> 02:37.090
2010 or same thing with the circle here.

02:37.630 --> 02:43.420
But 10 percent happier for instance it was only this part was true released years greater than 2010

02:43.690 --> 02:48.240
because author L name is Harris or Saunders In this case or gaming.

02:48.670 --> 02:52.040
OK so again that symbol right there.

02:52.320 --> 02:57.620
I forgot I made this nice little slide this animation that changes symbol is very very important.

02:57.640 --> 03:01.490
It changes the meaning entirely from the statement.

03:01.600 --> 03:07.120
So if we have two conditions with an ampersand between them or three or any number of conditions with

03:07.120 --> 03:12.790
ampersands it means that both sides must be true in order for the whole thing to be true as we've seen

03:12.790 --> 03:14.110
already.

03:14.140 --> 03:21.730
However with the OR operator it means only one side must be true for the whole thing to be true or both

03:21.730 --> 03:22.910
sides can be true as well.

03:22.930 --> 03:27.480
And I know that's a bit odd to talk about in this way without actual examples.

03:27.670 --> 03:32.350
So if we hop over again and we do the same thing I've been doing the last couple of videos and to type

03:32.350 --> 03:36.310
up a few example exercises and then we'll go over solutions.

03:36.680 --> 03:38.030
OK so I'm back here.

03:38.220 --> 03:44.920
I've got three just three this time that I'll use logical order to try them out and then I'll be back

03:44.920 --> 03:47.660
with a solution and I'm back already.

03:47.800 --> 03:48.370
OK.

03:48.480 --> 03:50.000
So first one here.

03:50.330 --> 03:51.220
40.

03:51.250 --> 03:53.340
Less than or equal to 100.

03:53.710 --> 03:55.400
Well that part's true.

03:55.730 --> 03:57.150
Forty is less than 100.

03:57.190 --> 03:59.020
So it doesn't matter what's over here.

03:59.020 --> 04:03.750
This whole thing is true because we only need one half to be true.

04:03.970 --> 04:13.680
Happens that negative 2 is not greater than zero but that's irrelevant because the left side is true.

04:13.690 --> 04:17.370
Moving on to this one 10 and greater than five is that true.

04:17.440 --> 04:19.040
Yes.

04:19.180 --> 04:20.970
So it doesn't matter what's on the right side.

04:20.980 --> 04:26.830
But that happens to also be true that the whole thing is true.

04:27.040 --> 04:33.520
So we get one and this last one bit of a curve ball is the letter A.

04:33.520 --> 04:35.210
Equal to the number five.

04:35.290 --> 04:36.460
Well that's not true.

04:37.270 --> 04:40.430
However this side says 3000 is greater than 2000.

04:40.450 --> 04:41.310
That is true.

04:41.320 --> 04:42.400
So the whole thing is true

04:45.400 --> 04:47.690
as you can see we get one for true.

04:48.130 --> 04:48.760
OK.

04:49.000 --> 04:50.220
Last thing before I forget.

04:50.230 --> 04:50.820
Just like with.

04:50.830 --> 04:54.190
And we can chain or together as many times we want.

04:54.190 --> 04:56.350
So it doesn't have to be something like this.

04:56.380 --> 05:04.420
So if I go back to this example it's like title author I'll name released your from books where author

05:04.420 --> 05:07.120
name is Aggers or release here is greater than 2010.

05:07.180 --> 05:10.960
So let's try adding an OR here and I'll spell it out this time.

05:10.960 --> 05:17.740
And let's say not only do we care or do we want to select things written by Eggers or released or greater

05:17.740 --> 05:18.630
than 2010.

05:18.640 --> 05:25.420
We'll also add another or which is stock quantity is greater than 100.

05:25.570 --> 05:28.460
So books that we have a lot of stock in as well.

05:28.510 --> 05:36.050
And let's also print stock quantity just like that just copy this whole thing.

05:36.200 --> 05:38.550
Paste it semi-colon.

05:39.050 --> 05:46.240
And if we look to see it makes a slight difference because we also get this.

05:46.250 --> 05:52.400
David Foster Wallace story collection in here which was written in 2004 which normally wouldn't make

05:52.400 --> 05:56.790
the cut with our previous version but because we added star quantity greater than 100.

05:57.110 --> 06:00.610
It's in here because stuck on the is greater than 172.

06:00.680 --> 06:03.780
So for some of these for instance a hologram for the king.

06:04.040 --> 06:05.460
All three parts are true.

06:05.690 --> 06:11.180
It's written by Aggers it's released after 2010 and it has more than 100 copies in stock.

06:11.360 --> 06:16.330
But then like for David Foster Wallace and oblivion only one part is true.

06:16.430 --> 06:17.120
The last part.

06:17.300 --> 06:22.580
So it just goes to show you that only one component even if we have three different conditions only

06:22.580 --> 06:26.000
one part has to be true for the entire thing to be true.

06:26.090 --> 06:29.780
And for it to be selected and spit back to us OK.

06:30.120 --> 06:36.210
So that's logical or one thing that I will point out that I know you're probably dying to get on with

06:36.210 --> 06:40.790
this video but you can combine or and and see how to do that in a little bit.
