Sql comparison operators: Difference between revisions
From wikinotes
(→REGEXP) |
(→REGEXP) |
||
Line 5: | Line 5: | ||
'[A-z][0-9]' # character range | '[A-z][0-9]' # character range | ||
'[0-9]*a' # Matches any or no occurrences of [0-9]. | '[0-9]*a' # Matches any or no occurrences of [0-9]. | ||
'^a' # matches lines starting with 'a' | '^a' # matches lines starting with 'a' | ||
'a$' # matches lines ending with 'a' | 'a$' # matches lines ending with 'a' |
Revision as of 17:58, 19 September 2021
REGEXP
'.' # any single character '[A-z][0-9]' # character range '[0-9]*a' # Matches any or no occurrences of [0-9]. '^a' # matches lines starting with 'a' 'a$' # matches lines ending with 'a' '^aaa$' # matches 'aaa'. not '*aaa*' (which is default in mySQL) 'aaa' # matches '.*aaa.*' unless anchored with '^' or '$'Example.
SELECT * FROM users WHERE name REGEXP '^Andr'
LIKE
glob-style matching (
%
represents any or no characters).SELECT * FROM users WHERE name LIKE 'Andr%';