All right.
So we have one more video here or at least one more tool for the toolbox before we get to the exercise
at the end of this section.
And that tool is something called like.
And I'll start off by saying, like, it's very useful.
It basically allows us to perform better searching of our data.
So if you think of when we saw how to use where, where would allow us to find exact matches so I could
do things like select star from books where title is exactly Harry Potter and the Sorcerer's Stone.
But what if I wanted to select all Harry Potter books?
I would want to do something like Select Star from books where title contains Harry Potter or starts
with Harry Potter or something like that.
And we don't have a way of doing that yet.
Until now with like so like allows us to do things like this.
Imagine someone comes into your bookstore if we have a bookshop and they say, There's a book I'm looking
for, but I can't remember the title.
I think the author's first name is David or maybe it's Dan or or Dave, and you could go over to your
system as a really helpful bookstore employee and you could just search for, let's say, books written
by authors whose first name starts with DA, which I guess is a very broad category.
But you could still do that if you searched for authors at like a Barnes Noble or a popular bookshop
or Amazon.
You can do that type of search and it will work.
It's just not that common.
But we could do the same thing for books.
Like I said, Harry Potter is a good example where we want to search for all the Harry Potter books,
not just the exact one word for word matched or character for character matched.
So that's where where comes in.
Now, I warn you, it's going to look a little bit odd when I show it to you.
But that's okay.
It's not that complicated.
There's just some weird symbols here.
So here's an example of using like where?
So this is ignoring the first part of the query, the select star from or the update or the delete or
whatever it is.
So blank where author f name like and then in quotes I have this percent sign d a percent sign.
So I'll tell you, first of all, what this is going to do is find where the author's first name has
the letters, DEA in it.
And these little things here, those percentage symbols kind of like that animation there.
Those are known as wild cards.
So that's basically the way that we specify.
We want to find author first names where there's something, anything at all.
It's a wild card.
So any characters and then these two exact characters, characters, DEA and then anything afterwards.
So it's basically a way of saying whatever, blank, anything, DEA and then whatever, anything else
afterwards.
And if we try using this right now, actually, you'll see what happens if we go over here and we do
a select and let's just do a title and author f name.
From books where and then we'll do author f name like and then this is where we need those wild card
symbols and we'll put D a in between.
So once again, this is saying anything followed by D A Exactly.
D So it can't be D and then s and then A It has to be de and then anything afterwards.
So if I hit enter now.
You'll see that it works.
We get these authors.
Dave, Dave, Dave, David, David, Dan and Frida.
And you might notice.
Well, Frida, that doesn't start with DA.
And you would be right.
It ends with DA, but it still meets this queries or it still meets the conditions for this query,
which is anything da anything.
So in this case, it's free, ID or free is meeting this and then we have DA and then this wild card.
There's nothing afterwards and that's perfectly fine.
This is not saying there has to be something after the and the or something before.
As you can see, we're matching D a V, so there's nothing before it.
That's fine.
Then Da and then V afterwards.
So basically this is all about pattern matching.
And if we wanted to refine this so that we only get author first names that start exactly with Dave
or sorry exactly with DA, we can do it like this.
All we do is leave off that first wild card, that first percentage sign, and that says, I want to
find author first names where they start with DA and then anything afterwards.
So it could be Dana, David, Dave, Dan, Darwin, whatever.
So if we just make that one small change and we delete that percentage sign.
You can see Frida is gone.
I'm sorry, Frida, because Frida no longer fits the pattern that we're matching.
Also, it's important to note that it is case insensitive.
As you can see, this is lowercase D and a and it still matches all these uppercase D's and lowercase
A's.
So if I wanted to do something slightly different, let's say search all books where the title has the
word the somewhere in there.
It's pretty simple.
It's just a select title from books where title like.
And if I just say the.
That's only going to give me books where it's exactly the.
And that's not what we want.
So we want something followed by the.
And if we just leave it like this, that's not going to give us anything, because this is specifying
we want books where the title has anything and then ends with the letters THG.
That's not really what we want.
So we'll add another wild card at the end.
And now that gives us all the books that have a title that has something, then tag and then something
else afterwards.
So you can see we get The Namesake a hologram for the King, The Circle, The Amazing Adventures of
Kavalier and Clay.
Consider the Lobster and then Lincoln in the Bardo.
Really good book, by the way.
I know I've said that like ten times.
It's a good book.
So that's the basics of using.
Like, these percentage signs are very common.
I know it looks kind of odd, but this is really, really important.
Think of when you're searching.
I don't know.
You're on.
If you use Reddit, if you're ever searching for things on Reddit behind the scenes, like is being
employed or if you're searching on whatever site you search on, there's some form of variation of this,
like going on where your query, whatever you search for is not being.
It's not only matching.
Exactly.
So when I search for an Amazon, I type in let's let's just go with my let's say Lord of the Rings.
I search Lord of the Rings.
It's not only going to give me books that have a title exactly of Lord of the Rings.
It's going to give me books that have Lord of the Rings in the title somewhere.
Obviously, their search is much, much more complicated, where it also searches things like through
comments and reviews and related books.
And there's this whole complicated graph network of how the search works.
But the core idea, the simplest search that you could implement uses like.