SQLite 3 reference · String Functions
SQLite LIKE Operator
Match a string against a pattern with % (any run of characters) and _ (one character). Case-insensitive for ASCII.
SQLite 3
Syntax
X LIKE pattern [ESCAPE e] | like(pattern, X)
Parameters
| Parameter | Description |
|---|---|
X |
The string to test. |
pattern |
% matches any number of characters, _ exactly one. |
ESCAPE e optional |
A character that makes the next % or _ literal. |
Return value
1 (true) or 0 (false).
Examples
SELECT name
FROM products
WHERE name LIKE '%desk%';
Output
name Desk Lamp Standing Desk Mat
SELECT 'a_b' LIKE 'a\_b' ESCAPE '\' AS literal_underscore,
'axb' LIKE 'a_b' AS any_char;
Output
literal_underscore | any_char 1 | 1
In other languages
ILIKE· PostgreSQL
Related
GLOB· Match a string against a Unix-style pattern with *, ? and [...]. Unlike LIKE, GLOB is case-sensitive.INSTR()· Return the 1-based position of the first occurrence of one string inside another, or 0 if it isn't found.LOWER()· Return a copy of a string with ASCII letters converted to lowercase. Handy for case-insensitive comparisons.- SQL LIKE and Wildcards · tutorial