One more quick note about working with the like operator.
There may be times you actually want to match a percent sign a book with a percent sign in it.
I know there's one in there because I had this insert it for this exact example or maybe some table
row that has an underscore in it.
But if those characters have a special meaning, it's not going to work, right?
I know that there's 10% happier in here, but if I try and select a book where title is like a percent
sign, that's just going to give me every single title, every single row, because percent sign matches.
It's a wild card.
It matches anything.
So instead of that, what I can do is escape it with a backslash.
If I put a backslash percent sign, all of a sudden that two character sequence, that means a literal
percentage sign.
This percent sign is a wild card.
That's a wild card.
These two combine to mean one in exactly one actual percent sign.
So let's try that where the title is like a percent sign backslash in front of it.
But that's not going to work.
Why not?
Because we would have to match something exactly named percent sign, but instead we want a percent
line in the middle of our title or at the beginning of the title or at the end.
We don't care.
We just want it somewhere.
Imagine that we had this example here, right?
This is saying the letter A somewhere within a string.
But when I do a backslash percent sign, we're saying a percent sign character somewhere within a string
and we get 10% happier.
Perfect.
I don't think I have anything with an underscore in it, but I have the exact same syntax to escape
an underscore.
I use a backslash underscore and SQL knows that we're actually looking for the exact character.
Underscore.
It doesn't mean a wild card anymore.
Oh, right.
We have fake book.
How did I forget we inserted fake book, so fake underscore book.
We can now match that using that underscore escape character.
And that's it for like.