String functions
LIKE
Reference material for LIKE function
The LIKE is used for pattern matching to find similar strings in data. It’s often employed in the WHERE clause to filter results based on specific patterns. LIKE
is case-sensitive; use ILIKE for case-insensitive pattern matching.
Syntax
Parameters
Parameter | Description | Supported input types |
---|---|---|
<expression> | Any expression that evaluates to TEXT . | TEXT |
<pattern> | Specifies the pattern to match (case-sensitive). | TEXT constant. SQL wildcards are supported: * Use an underscore ( _ ) to match any single character* Use a percent sign ( % ) to match any number of any characters, including no characters. |
Return Type
BOOLEAN
Example
Find nicknames from the players
table that partially match the string “joe” and any following characters as follows:
Returns:
Note that the following would return no results, as LIKE
matches case-sensitively, unlike ILIKE
:
Find nicknames from the players
table that have a specific pattern:
The pattern %oe_e% signifies any string that contains “oe” followed by any character (_ acts as a wildcard for a single character) and then “e”.
Returns