WEBVTT

00:00.120 --> 00:01.040
So that's the basics.

00:01.080 --> 00:05.660
But there's another wildcard character that I'll show you which is the underscore.

00:05.970 --> 00:09.250
So here I have a really weird query.

00:09.270 --> 00:13.660
This is for underscores in a row they will have to trust me that it's four.

00:13.890 --> 00:17.070
And it was hard to tell what this will do.

00:17.310 --> 00:24.690
So we're searching stock quantity which is a number and we're trying to find where it's like for underscores

00:25.190 --> 00:31.380
and basically an underscore is a wildcard to specify exactly one character any character but exactly

00:31.380 --> 00:31.870
one.

00:31.920 --> 00:37.510
So four of them in a row is saying I want to find where the stock quantity is for characters long.

00:37.980 --> 00:41.110
So let me show you why we might want to do that.

00:41.130 --> 00:50.390
Why do a select stock title and stock quantity from books just like that.

00:50.520 --> 00:58.000
You can see that we have Star quantity of to her sorry two digit two tickets 32 43 three.

00:58.150 --> 01:00.190
She is giving me a tough time.

01:00.300 --> 01:02.520
Digits 154.

01:02.970 --> 01:09.450
And then this great book linking in the bardo has a thousand copies in stock is brand new.

01:09.450 --> 01:10.860
People don't know about it yet.

01:11.130 --> 01:11.730
They're not buying it.

01:11.730 --> 01:13.140
I'm sure people will buy it soon though.

01:13.170 --> 01:16.400
Once Of course they they realize what a great book it is.

01:16.410 --> 01:23.190
So if I wanted to select books where stock quantity is four digits long I could use that wild card.

01:23.220 --> 01:24.490
So let me just say that again.

01:24.570 --> 01:32.190
So select title and stock only from books where stock on or the like.

01:32.940 --> 01:39.580
And all I have to do so just to clarify if I did this that wild card just means anything.

01:40.020 --> 01:41.810
So that's going to give us everything.

01:42.060 --> 01:44.330
And if I do four of them it doesn't make a difference.

01:44.610 --> 01:46.230
That's not saying four characters.

01:46.230 --> 01:49.060
That's just four different ways of saying anything at all.

01:49.080 --> 01:50.190
It could be nothing.

01:50.190 --> 01:53.550
It could be a thousand characters it doesn't matter.

01:53.550 --> 02:03.660
So by adding underscores that's for there you'll see I get Lincoln in the bardo or I could do two underscores

02:04.620 --> 02:07.980
and I only get the two digit stock quantities.

02:07.980 --> 02:11.250
Now that's not to say the only time you use underscores is when you're trying.

02:11.340 --> 02:11.690
Yes.

02:11.700 --> 02:13.630
Blue is my cat.

02:14.070 --> 02:15.230
Are you going to say hi.

02:15.450 --> 02:17.520
She's now sitting on the computer.

02:18.240 --> 02:18.520
OK.

02:18.540 --> 02:20.620
So back to where I was.

02:20.730 --> 02:23.450
Get this cat hair out of here.

02:23.490 --> 02:29.920
The underscore is not only used and actually it's not even primarily used for counting digits like that

02:30.240 --> 02:33.480
but it's a way of specifying exactly one character.

02:33.480 --> 02:38.460
Like I said Let's say that we're working with phone numbers and in the US they might look something

02:38.460 --> 02:39.630
like this.

02:39.660 --> 02:45.120
So we have an area code in parentheses and then three digits dash four digits.

02:45.440 --> 02:51.900
And if we wanted to match that pattern we would have something that looks like this like and we'd have

02:51.900 --> 02:58.020
a first print to see and if we just put this wildcard there that's going to say any number any letters

02:58.020 --> 03:04.590
whatever it is in between those parentheses but we're actually looking for three digits and then another

03:04.590 --> 03:06.280
three digits after that parentheses.

03:06.510 --> 03:09.380
Then a dash and then four digits.

03:09.990 --> 03:15.750
So basically we have these two wild cards at the end of the day present sign which means anything or

03:15.750 --> 03:16.580
nothing.

03:17.130 --> 03:20.530
And then underscore which is exactly one thing.

03:20.790 --> 03:26.500
And you can chain them together to match patterns then that brings up another question which is but

03:26.510 --> 03:30.290
what if I'm searching for a book that has a percent sign in it.

03:30.540 --> 03:32.140
How would I do that.

03:32.190 --> 03:39.030
And you may have noticed that I expertly planted a book title with the percent sign and I was thinking

03:39.030 --> 03:41.010
ahead for once.

03:41.010 --> 03:43.180
How would we select that.

03:43.410 --> 03:47.730
Or there's also a book title that it's not so creative It has an underscore in it.

03:47.730 --> 03:49.110
How would I select that one.

03:49.350 --> 03:56.910
If these characters are special wildcard characters how do I actually search for the exact character

03:57.060 --> 04:00.010
percent side or the exact character underscore.

04:00.030 --> 04:03.440
And the answer is actually pretty straightforward.

04:03.900 --> 04:07.230
We use what's known as an escape character.

04:07.560 --> 04:14.250
In this case I always forget which one is backwards and forwards slash but whichever slash This is the

04:14.250 --> 04:15.860
one over the turkey.

04:15.900 --> 04:23.300
Pretty sure that his backslash so backslash percent signed is going to match a percent sign.

04:23.310 --> 04:27.830
So this entire thing right here is basically saying percent sign.

04:28.470 --> 04:32.510
Likewise with underscores backslash underscore is the escape character.

04:32.760 --> 04:34.710
So let's put that into practice.

04:34.740 --> 04:35.650
Let's try it out.

04:35.670 --> 04:44.430
So a select title from books and we'll just do that first all and you'll see we've got 10 percent happier

04:44.820 --> 04:46.110
and then fake under scorebook.

04:46.110 --> 04:47.830
So let's start with 10 percent happier.

04:48.090 --> 04:56.220
So I want to select title from books from books where title like and just I mean this should be clear

04:56.220 --> 04:56.480
right now.

04:56.490 --> 05:01.490
But if we tried to do this that's not going to work that's going to give us everything.

05:01.740 --> 05:07.770
But if I tried to say okay percent signed that means anything and then a percent signed and then anything

05:07.770 --> 05:12.090
afterwards that's not going to work either because that's basically just three different ways of saying

05:12.270 --> 05:13.890
anything at all in the title.

05:13.890 --> 05:17.040
So that's where we need our backslash.

05:17.060 --> 05:24.000
Now you could read this as you could condense this to say exactly a percent sign 1 percentage sign anything

05:24.000 --> 05:25.870
before anything after.

05:26.370 --> 05:27.200
And there we go.

05:27.360 --> 05:30.210
That's how we get 10 percent happier.

05:30.210 --> 05:31.540
Same thing with the underscore.

05:31.640 --> 05:33.630
I won't go through that whole routine again.

05:34.620 --> 05:41.950
We just replaced that backslash present with backslash underscore and that gives us fake book.

05:41.980 --> 05:42.540
All right.

05:42.720 --> 05:45.480
So that's all there is to like for now.

05:45.840 --> 05:47.080
It's very very useful.

05:47.130 --> 05:49.090
We'll be using it quite a bit in this course.

05:49.110 --> 05:54.100
It's probably one the most commonly used things in my school are in school when doing queries.

05:54.330 --> 05:59.970
In all likelihood you won't be matching percent signs or underscores all that often but you'll be doing

05:59.970 --> 06:06.390
things like this all the time where you're using the percent wildcard and the underscore wildcard to

06:06.390 --> 06:07.460
match patterns.

06:07.810 --> 06:08.300
OK.

06:08.340 --> 06:09.600
Next up exercise is.
