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). The pattern can be a constant or any TEXT expression, including a column reference. | TEXT. 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
The following example finds all players whose nickname starts withjoe using the % wildcard, which matches any sequence of characters:
| playerid int null | nickname text null | email text null |
|---|---|---|
| 145 | joel53 | james96@example.com |
| 1356 | joel35 | smithaustin@example.net |
| 2823 | joe12 | thompsondana@example.org |
| 3232 | joe30 | gabrielle32@example.org |
| 3872 | joemata | nashrodney@example.com |
| 4655 | joel68 | browntina@example.org |
| 4880 | joel47 | kristinarivas@example.com |
Rows: 7Execution time: 2.70ms
LIKE is case-sensitive. The following example returns no results because no nicknames start with uppercase 'Joe':
| playerid int null | nickname text null | email text null |
|---|
Rows: 0Execution time: 6.48ms
_ wildcard matches exactly one character. The following example finds players whose nickname contains oe, followed by any single character, then e:
| playerid int null | nickname text null | email text null |
|---|---|---|
| 2845 | jonathanschroeder | donnaglenn@example.net |
| 3079 | ianschroeder | cfarmer@example.com |
| 4329 | jennyschroeder | phillipsdana@example.org |
| 4787 | schroederkim | htapia@example.net |
Rows: 4Execution time: 7.61ms
Example using a non-constant pattern
The pattern doesn’t have to be a literal. You can match each row against a pattern stored in another column. For example, given afilters table that holds one pattern per row, join it with players to return the nicknames that match any of the patterns:
joe% and %long, this returns nicknames such as joe12, joemata, and joshualong.