WEBVTT

00:00.320 --> 00:01.070
All right.

00:01.080 --> 00:05.410
So we have one more video here or at least one more tool for the toolbox.

00:05.550 --> 00:11.510
Before we get to the exercise at the end of this section and that tool is something called like.

00:11.790 --> 00:14.360
And I'll start off by saying like is very useful.

00:14.400 --> 00:19.930
It basically allows us to perform better searching of our data.

00:20.010 --> 00:25.590
So if you think of when we saw how to use where where would allow us to find exact matches.

00:25.590 --> 00:26.830
So I could do things like.

00:26.910 --> 00:30.190
So like star from books where title is exact.

00:30.180 --> 00:33.980
The Harry Potter and the Sorcerer's Stone.

00:34.380 --> 00:40.140
But what if I wanted to select all Harry Potter books I would want to do something like select star

00:40.140 --> 00:46.120
from books where Title contains Harry Potter or starts with Harry Potter or something like that.

00:46.290 --> 00:54.510
And we don't have a way of doing that yet until now with like so like allows us to do things like this.

00:54.510 --> 00:56.210
Imagine someone comes into your bookstore.

00:56.310 --> 01:03.220
If we have a bookshop and they say there's a book I'm looking for but I can't remember the title.

01:04.240 --> 01:07.010
I think the author's first name is David.

01:07.330 --> 01:10.450
Or maybe it's Dan or or Dave.

01:10.930 --> 01:15.880
And you could go over to your system has a really helpful bookstore employee and you could just search

01:16.030 --> 01:23.380
for let's say books written by authors whose first name starts with DA which I guess is a very broad

01:23.380 --> 01:30.340
category but you could still do that if you searched for authors at like Barnes Noble or a popular bookshop

01:30.340 --> 01:31.460
or Amazon.

01:31.660 --> 01:35.210
You can do that type of search and it will work.

01:35.260 --> 01:38.100
It's just not that common.

01:38.470 --> 01:43.210
But we could do the same thing for books like I said Harry potter is a good example where we want to

01:43.210 --> 01:48.270
search for all the Harry Potter books not just the exact one word for word matched her character for

01:48.280 --> 01:49.250
character matched.

01:49.510 --> 01:51.180
So that's where Ware comes in.

01:51.190 --> 01:56.380
Now I warn you it's going to look a little bit odd when I show it to you but that's OK.

01:56.680 --> 01:58.170
It's not that complicated.

01:58.180 --> 02:00.110
There's just some weird symbols here.

02:00.970 --> 02:04.840
So here's an example using Like where.

02:04.840 --> 02:11.350
So this is ignoring the first part of the query the select start from the update or the daily or whatever

02:11.350 --> 02:12.170
it is.

02:12.280 --> 02:23.410
So blank where author name like and then in quotes I have this present sign da present sign.

02:24.700 --> 02:30.310
So I'll tell you first of all what this is going to do is find where the author's first name has the

02:30.310 --> 02:32.410
letters DA in it.

02:33.220 --> 02:37.650
And these little things here those percentage symbols kind of like that animation there.

02:37.780 --> 02:40.130
Those are known as wild cards.

02:40.150 --> 02:45.970
So that's basically the way that we specify We want to find author first names where there is something

02:46.450 --> 02:53.050
anything at all it's a wild card so any characters and then these two exact character characters DA

02:53.060 --> 02:54.940
and then anything afterwards.

02:55.780 --> 03:00.770
So it's basically a way of saying whatever blank anything.

03:00.910 --> 03:03.650
DA And then whatever anything else afterwards.

03:04.620 --> 03:11.250
And if we try using this right now actually you'll see what happens if we go over here and we do a select

03:11.700 --> 03:24.470
and let's just do a title and author name from books where will do author name like.

03:24.970 --> 03:30.820
And then this is where we need those wild card symbols and we'll put da in between.

03:30.820 --> 03:39.350
So once again this is saying anything followed by da exactly DA so can't be d and then S and A.

03:39.550 --> 03:42.730
IT HAS TO BE DA and then anything afterwards.

03:42.730 --> 03:47.420
So if I hadn't heard of you'll see that it works.

03:47.500 --> 03:48.550
We get these authors.

03:48.550 --> 03:52.800
Dave Dave Dave David David Dan and Frida.

03:53.440 --> 03:58.020
And you might notice for Frieda that doesn't start with DA and you would be right.

03:58.390 --> 04:04.990
It ends with da but it still meets this queries xpect it still meets the conditions for this query which

04:04.990 --> 04:06.380
is anything.

04:06.410 --> 04:08.130
Da anything.

04:08.620 --> 04:19.930
So in this case it's f r e I d or f r e i is meeting this and then we have da And then this wildcard

04:19.990 --> 04:22.990
there's nothing afterwards and that's perfectly fine.

04:22.990 --> 04:27.240
This is not saying there has to be something after the DNA or something before.

04:27.400 --> 04:30.770
As you can see we're matching da V.

04:31.090 --> 04:34.620
So there's nothing before it that's fine then da.

04:34.750 --> 04:36.540
And then afterwards.

04:36.850 --> 04:39.520
So basically this is all about pattern matching.

04:39.520 --> 04:46.660
And if we wanted to refine this so that we only get author first names that start exactly with Dave

04:47.230 --> 04:54.370
or sorry exactly with Da we can do it like this all we do is leave off the first wildcard the first

04:54.370 --> 04:55.020
percent and so on.

04:55.030 --> 05:02.830
And that says I want to find author first names where they start with da and then anything afterwards.

05:02.830 --> 05:05.010
So it could be Dana David Dave.

05:05.180 --> 05:08.320
Dan Darwin or whatever.

05:08.650 --> 05:15.760
So if we could just make that one small change and we delete that percentage sign you can see Frita

05:15.760 --> 05:16.240
is gone.

05:16.240 --> 05:20.650
I'm sorry Freeda because Freeda no longer fits the pattern that we're matching.

05:21.720 --> 05:27.510
Also it's important to note that it is case insensitive as you can see it is lowercase DNA and it still

05:27.510 --> 05:30.750
matches all these uppercase DS in lowercase A's.

05:31.380 --> 05:36.870
So if I wanted to do something slightly different let's say search all books where the title has the

05:36.870 --> 05:39.610
word the somewhere in there.

05:39.780 --> 05:40.510
It's pretty simple.

05:40.530 --> 05:47.520
It's just a select title from books where title like.

05:48.090 --> 05:54.130
And if I just say that's only going to give me books where exactly the.

05:54.510 --> 05:55.770
And that's not what we want.

05:55.770 --> 06:01.680
So we want something followed by the end if we just leave it like this.

06:01.830 --> 06:06.930
That's not going to give us anything because this is specifying we want books where the title has anything

06:06.990 --> 06:09.480
and then ends with the letters THG.

06:09.570 --> 06:11.040
That's not really what we want.

06:11.670 --> 06:14.910
So we'll add another wildcard at the end.

06:15.060 --> 06:22.230
And now that gives us all the books that have a title has something then THG and then something else

06:22.230 --> 06:23.140
afterwards.

06:23.610 --> 06:27.640
So you can see if we get the namesake a hologram for the king the circle the masing adventure to Kavli

06:27.650 --> 06:28.410
and clay.

06:28.410 --> 06:30.930
Consider the lobster and then Lincoln in the bardo.

06:31.320 --> 06:32.670
Really good book by the way.

06:32.670 --> 06:34.500
I know I've said it like 10 times.

06:34.510 --> 06:35.690
Good work.

06:36.060 --> 06:42.360
So that's the basics of using like these percentage signs are very common.

06:42.600 --> 06:46.470
I know it looks kind of odd but this is really really important.

06:46.500 --> 06:48.150
Think of when you're searching.

06:48.420 --> 06:53.420
I don't know if you're on if you use read it if you're ever searching for things on Reddit.

06:53.490 --> 07:00.860
Behind the Scenes like is being employed or if you're searching on whatever site you search on there's

07:00.870 --> 07:06.280
some form of variation of this like going on where you're query whatever you search for.

07:06.810 --> 07:09.000
It's not being it's not only matching.

07:09.000 --> 07:10.230
Exactly.

07:10.230 --> 07:13.940
So when I search for you know on Amazon I type in.

07:14.070 --> 07:17.520
Let's let's just go with my let's say Lord Of The Rings I search Lord Of The Rings.

07:17.550 --> 07:19.880
It's not only going to give me books that have a title.

07:19.920 --> 07:20.870
Exactly.

07:20.920 --> 07:21.860
Of Lord Of The Rings.

07:22.070 --> 07:25.040
It's going to give me books that have Lord Of The Rings in the title somewhere.

07:25.290 --> 07:30.600
Obviously their search is much much more complicated where it also searches things like you know through

07:30.600 --> 07:33.900
comments and reviews and related books.

07:33.900 --> 07:37.800
And there's this whole complicated graph network of how the search works.

07:37.800 --> 07:42.210
But the core idea the simplest search that you could implement uses like.
