-
Notifications
You must be signed in to change notification settings - Fork 689
LIKE
Mathias Wulff edited this page Dec 16, 2025
·
5 revisions
Match expression with pattern.
Syntax:
expression LIKE patternThe pattern syntax uses these special characters:
-
%- any amount of any character -
_- Exactly one character of any type
| Pattern | Regex | Matches | Doesn't Match |
|---|---|---|---|
A% |
/^A[\\s\\S]*$/i |
A, AB, Apple, ANYTHING | Banana |
%A |
/^[\\s\\S]*A$/i |
A, BA, PIZZA | AB, Apple |
_A |
/^.A$/i |
BA, CA, 1A | A, AAA |
A_ |
/^A.$/i |
AB, A1, AZ | A, ABC |
_4_ |
/^.4.$/i |
444, a4b, X4Y | 4, 44, 404* |
%4% |
/^[\\s\\S]*4[\\s\\S]*$/i |
4, 444, 1234, a4b | 123, abc |
*Note: '404' does NOT match '4' because:
- First character: '4' (matches
_) - Second character: '0' (needs to match literal '4') ❌ FAILS
- Third character: '4' (would match
_)
In AlaSQL the match is case-insensitive meaning we are aligning with MySQL, MSSQL and SQLite.
| Database | LIKE Default | ILIKE Support | Notes |
|---|---|---|---|
| PostgreSQL | Case-SENSITIVE | ✅ Case-insensitive | ILIKE is PostgreSQL extension |
| Oracle | Case-SENSITIVE | ❌ | Use UPPER()/LOWER() instead |
| MySQL/MariaDB | Case-INSENSITIVE* | ❌ | *Depends on collation (default: ci) |
| MSSQL | Case-INSENSITIVE* | ❌ | *Depends on collation (default: ci) |
| SQLite | Case-INSENSITIVE** | ❌ | **ASCII only; case-sensitive for non-ASCII |
| AlaSQL | Case-INSENSITIVE | All variants are case-insensitive |
Please note that Postgres and Oracle behaves differently and the SQL might need to be adapted.
See also: MATCH
© 2014-2026, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo