Sqlite Like % and _
In SQLite, use %
in the LIKE
statement to match any series of characters, and _
to match a solitary character:
In the Wild of Special Characters
To search for %
or _
as literal characters, use the ESCAPE
keyword.
Just remember, our escape characters here are as freely chosen as a Netflix movie on a lazy Sunday!
Multi Underscore and Percentage Saga
One underscore (_
), two underscore (__
), red underscore, blue underscore! Multiple underscores (___
) match a definitive set of characters while multiple %
(%%%
) simply plays the part of that elusive wildcard, indifferent to the length:
Case of the GLOB Patterns
In SQLite, GLOB
comes into the picture for case-sensitive globetrotting:
Where *
stars as the wildcard and ?
questions a single character.
No One Puts Case Sensitivity in a Corner
SQLite's LIKE
operator throws case out of the window. In contrast, GLOB
is the polite detective, always minding its case:
Pattern Matching: The Master Class
SQLite supports pattern matching beyond basic characters. Check out this intricate LIKE
query:
This query uncovers strings that commence with C
, succeeded by any two characters and rounded off neatly with a d
.
Was this article helpful?