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 is 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.
So like star from books where title is exact.
The 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 has 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 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 her character for
character matched.
So that's where Ware comes in.
Now I warn you it's going to look a little bit odd when I show it to you but that's OK.
It's not that complicated.
There's just some weird symbols here.
So here's an example using Like where.
So this is ignoring the first part of the query the select start from the update or the daily or whatever
it is.
So blank where author name like and then in quotes I have this present sign da present 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 DA 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 is something
anything at all it's a wild card so any characters and then these two exact character characters DA
and then anything afterwards.
So it's basically a way of saying whatever blank anything.
DA 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 name from books where will do author name like.
And then this is where we need those wild card symbols and we'll put da in between.
So once again this is saying anything followed by da exactly DA so can't be d and then S and A.
IT HAS TO BE DA and then anything afterwards.
So if I hadn't heard of you'll see that it works.
We get these authors.
Dave Dave Dave David David Dan and Frida.
And you might notice for Frieda that doesn't start with DA and you would be right.
It ends with da but it still meets this queries xpect it still meets the conditions for this query which
is anything.
Da anything.
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
there's nothing afterwards and that's perfectly fine.
This is not saying there has to be something after the DNA or something before.
As you can see we're matching da V.
So there's nothing before it that's fine then da.
And then 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 the first wildcard the first
percent and so on.
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 or whatever.
So if we could just make that one small change and we delete that percentage sign you can see Frita
is gone.
I'm sorry Freeda because Freeda no longer fits the pattern that we're matching.
Also it's important to note that it is case insensitive as you can see it is lowercase DNA and it still
matches all these uppercase DS in 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 that's only going to give me books where exactly the.
And that's not what we want.
So we want something followed by the end 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 wildcard at the end.
And now that gives us all the books that have a title has something then THG and then something else
afterwards.
So you can see if we get the namesake a hologram for the king the circle the masing adventure to Kavli
and clay.
Consider the lobster and then Lincoln in the bardo.
Really good book by the way.
I know I've said it like 10 times.
Good work.
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 if you're on if you use read it 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 you're query whatever you search for.
It's not being it's not only matching.
Exactly.
So when I search for you know on 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 you know 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.