[MySQL] 01_RegularExpression - UzanR/UzCodingNewLife GitHub Wiki
Basic Syntax
Select column_list From table_name Where string_column REGEXP pattern;
MetaCharacter
- [^] matches the position at the beginning of the searched string
- [$] matches the position at the end of the searched string
- [.] matches any single character
- … matches any character specified inside the square brackets
- ^… matches any character not specified inside the square brackets
- [p1|p2] matches any of the patterns p1 or p2
- [*] matches the preceding character zero or more times
- [+] matches preceding character one or more times
- [{n}] matches n number of instances of the preceding character
- [{m,n}] matches from m to n number of instances of the preceding character
Like Operator
Basic syntax
expression LIKE pattern ESCAPE escape_character
Wildcard character
Find name start with a
Select first_name from employees where firstname LIKE 'a%';
Find name start with T, end with m
Select first_name from employees where firstname LIKE 'T_m';