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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

X LIKE pattern [ESCAPE e]  |  like(pattern, X)

Parameters

ParameterDescription
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

Contains a word, any caseTry it yourself
SELECT name
FROM products
WHERE name LIKE '%desk%';

Output

name
Desk Lamp
Standing Desk Mat
Escape wildcardsTry it yourself
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

Was this page helpful?