I will call you back again to another lecture in MySQL.
And in this video lecture let's go ahead and look at wildcard characters.
So in MySQL we have the percentage and we have the underscore.
And both of these characters helps us a lot in order to do some important job in our queries.
So in MySQL you want to be able to find maybe a specific character or a character that started with
a this or that.
Then you go ahead and use the wildcard characters.
So the wildcard characters helps us to substitute one or more characters in a string.
All right.
So I'm using the word characters and most of us will be like, what is going on?
What is happening?
Let's go ahead and give an example of this.
Let me say I want to check the first name or the last name.
Then I want the name that started with P.
Every name that does similar with P or names that start with A or B, S, m, Q, or z for the first
name or for the last name.
I want the names that started with a, j, C, R, S, or g.
Now how can you be able to do this?
So I know as a beginner you might be like, okay, I can be able to select that maybe row and say select
all from your students table.
But why?
So at this point just t correct.
Then let's move ahead and check it out.
Now let's add a Y or a week class.
And most of us would be like okay, let's go here and see where the first name or the last name is the
one you want to check out.
Maybe the first name is equal and let me see.
Want to check for the one that starts with Z.
So if I go ahead and insert Z right in there.
So if you ever do that it means that you want to return nothing.
Let's go ahead and check that out.
No.
If something would be printed out for us Now, if I execute the query and you can see the tables are
empty.
Why?
Now what you need to do is when you're using the white characters, you don't use the equal sign.
You use what is called the keyword known as like.
And when you use like, then you go ahead and use one of these characters, the percentage or the underscore.
And if you want to get the names that started with Z, you go ahead and use the percentage.
So and because we want to understand with Z and not the one that ends with Z, go ahead and put the
percentage at the back.
Because if z comes first, it will return the one that started with z.
What is z comes last, it will return the one that starts with that ends with z.
Go ahead and check it out.
So I have gender and you can see Z started with a z.
And let's go ahead and check out maybe Peter.
And let's go ahead and run this and check it out Peter.
know if I want to check out.
Maybe I want the one that stay with R if I run this.
Let's go ahead and put R here and check out this.
We don't have any first name associated with R, but let's go ahead and place this R at the back of
this and check out what we need to get now is the ones that ends with R.
So it's going to be the one that ends and no one hit wonder status.
So if your R goes at the back of the percentage it means one at ends.
But if the R comes in the front, it means the one that started with R.
But now I want to check for the ones that ends with R.
Then go ahead and run this and check it out.
We have pizza, Oscar and Lucinda in that same way.
I'll go ahead and change this to last name and let's check if we have last name that ends with R, and
go ahead and execute this query.
We don't have anyone.
Well let's go ahead and change that to E and check if we have last name that ends with R.
And this is the cutest query.
we have.
Jude and Grace.
Now let's go ahead and, uh, place this, uh, right in here.
I don't even know if we have the first name that started with E.
The last name does start with E.
I have to check.
We don't have anyone.
Well, let's go ahead and put that something like H because I believe we have H and check out this.
So we have last name.
Hillary.
Hillary center with H.
What if we go back and place this at the back?
It means we're looking for the last name that ends with H.
Go ahead and check it out.
We have Smith.
So Smith ends with H.
So it is in a way it's a wild card in MySQL.
And uh I hope that is very, very cool.
Now what if we go ahead and add more characters.
Let's go ahead and see.
We want the one, maybe the last name that started with, uh, p a.
I don't even know.
What if we have that?
Let's go ahead and check this out.
We don't ever have that.
But let's say we have James G.
So let's go ahead and check it out.
So oh we don't have anyone that started with a let's go ahead and show our table again so we can start
from there.
Okay.
We have Jude and not James.
So go ahead and place this back again.
And let's go ahead and change this to Jew.
And let's check it out.
So we have Jude.
And Jude starts with a j u.
So now we can add more.
And that go ahead and print out for you.
All right.
Let's go ahead and check in Roman dates that enroll within 2092 or 2091.
What we need to do is go over here and change this last name and change the last name a while and see
a row underscore date.
Uh, I want to leave the percentage, and I'm going to say this is a 2092 and go ahead and check it
out.
So Oscar enrolled in 2092 out of 2091.
Go ahead and check it out.
So we have a Barack and Sarah in row in 2091.
So this is the way you use the white cat character.
So there's another character that is remaining and that is the underscore the underscore white character
we use to return any random character.
So let's go ahead and find any department with random character length.
So number here and see where department.
So I'm going to use the underscore right now.
So department and uh go right in here and see underscore then length.
Then let's go ahead and execute this query and check if that will get anything for us.
And then what happens here is we have electrical we have electronics.
All right.
So all I need to do is I'll go over and let's say maybe electronics.
All right.
Now go ahead and execute this query.
and the electronics.
So if you want to remove the last one, because the reason why I removed it is that you're going to
replace the ones you didn't show with white characters on the score.
Let's go ahead and say, if I want to just show this, I'm going to say I will have a one, two, three,
four, five, six.
So I'm going to replace these six characters with underscore, say one, two, three, four, five,
six.
Then go ahead and execute this query and check it out.
Electronics.
So if I remove one of it and run this code I have electric car because the electric car is five after
after the length.
So this is how this works because I want to take it one step at a time if I want to check out.
So go ahead and say I want maybe Silverstone I will see.
I'm going to say s underscore.
The first underscore is for C and the second underscore is for I, then VI.
Then if I should run this code let's go ahead and check it out.
Civil.
Then if I should remove l I have to replace that with.
Underscore in order to get civil.
What if I should remove the L?
I'm not going to get anything.
Check it out.
So this is the way you use the underscore.
You're going to also always replace any of the values which you don't want to show with underscore in
order to get that.
Let's go ahead and check in raw date.
So in raw underscore date maybe I want to check out maybe people that enroll on November.
So I'm going to check out the EDA is going to be four characters 2019 or 2018 is A1234.
Then I want to check the error in November.
And I don't want to mind the date they got on the president to underscore one two.
Then go ahead and run this code and check it out.
So now I got the people that enrolled in November and I can see that.
So I have replaced 2091 with our, uh, the full underscores, and I replaced 18 with the two underscore.
Now, if I should go ahead and replace the months with double underscore, then I'll go ahead and say,
maybe I want people to enroll in zero two.
And I don't know if we have that.
Let's go ahead and take it out so we don't have that.
I'll go ahead and cut off these.
Then let's go ahead and run this and check maybe any of the dates.
So we have our date was six 2418 zero one and zero three.
Now if I should go ahead and put this back again I want people that enroll in 24.
Then go ahead and run this.
I check it out.
So I have an Oscar Electrical enroll in 2022, zero seven, 2024.
And if I change that to zero three, I think we have that and we have Zendaya Grace.
So this is a way this, uh, stuff actually works.
And you can actually also combine the two.
Let's let's go ahead and combine the two and see how the two works.
I'm going to say I want a department.
Let's go ahead and put this as a department.
And I'll go ahead and remove this.
So and that department is going to start with anything else.
And then put an L.
Then it starts.
L precede that.
Go ahead and check this out.
Let us know if we have that L.
So the very first one I replaced that with a e, which is the underscore.
And then the anything that comes behind I don't want to put a underscore maybe in it number of times
because it's not going to either return uh, electronics or electrical, because if I should do that,
I have to put seven underscores or six underscores for electronics and five underscore for electrical.
So you can see how this works.
Now what if we have uh, let's go ahead and say I put this to be maybe civil.
And let's go ahead and check this out.
We don't have anything right in here.
So if I should do that, let's go ahead and, uh, put another one maybe.
See.
And I that is then you can go ahead and replace this with a V, then just go ahead and run this and
check it out.
We have civil.
So in that way I was able to replace the PSI with double underscore, then the V then anything that
comes on.
And I want to put that with the underscore.
That is a way to combine these two wild cards.
So go ahead and practice with that.
I hope that is cool.
So to help you to query your table and when you work in large organizations, you can actually use all
these things and see how good they are.
So proud with it.
And if you have any question, please go ahead and use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.