LIKE
Description
The LIKE operator is used in SQL queries to match strings based on a specified pattern. It can help you find data that contains specific characters or patterns. When using the LIKE operator, you can use wildcards to represent one or more characters.
Parameters
- str (string): The original string to be matched.
- pattern (string): The pattern string containing wildcards.
Return Value
Returns a boolean value indicating whether str matches pattern.
Wildcard Explanation
%
: Represents any number of characters (including zero characters)._
: Represents any single character.
Usage Example
- Match strings that start with "Hello":
Results:
- Through a string with two characters "lo":
Results:
- Match strings that contain "lo" and end with "ld":
Results:
- Use a single character wildcard to match strings containing "oW":
Results:
- Combine with the NOT keyword to find strings that do not match a specific pattern:
Results: