How do I search SQLite text for a pattern with LIKE?
Quick answer
Use LIKE in a WHERE clause. In its pattern, % matches any sequence of characters, including none, while _ matches exactly one character. For example, name LIKE 'Al%' finds names beginning with Al. SQLite’s default LIKE ignores ASCII letter case, but is case-sensitive for Unicode characters beyond ASCII. [S1]
The question, the details, the next step.
A practical checklist
Write the known text exactly as it appears in your sample values.
Use
%where any number of characters, including none, may occur.Use
_where exactly one character may occur.Choose whether the pattern should match a prefix, a substring, or a fixed-length shape.
Test the query against representative rows and inspect the returned names.
For non-ASCII case matching, verify behavior in your SQLite setup; default behavior is not broad Unicode case folding.
A few more useful answers
Does `Al%` also match the name `Al`?
Yes. % can match an empty sequence, so the pattern can match the prefix by itself as well as longer text. [S1]
How do I find text anywhere in a name rather than only at the start?
Place % before and after the text, such as LIKE '%Jo%'. That allows characters on either side of the substring. [S1]
Will default SQLite LIKE match uppercase and lowercase Unicode letters as equivalent?
Not generally: the documented default is case-insensitive for ASCII letters and case-sensitive for Unicode characters beyond ASCII. The ICU extension provides broader Unicode case folding. [S1]
Sources
References used for this guide.
- [S1] SQLite SQL Language Expressions: LIKE patterns and case behavior sqlite.org · Checked
