|
Answer» In MySQL, regular expressions are used in queries for searching a pattern in a STRING.
- * Matches 0 more INSTANCES of the string preceding it.
- + matches 1 more instances of the string preceding it.
- ? Matches 0 or 1 instances of the string preceding it.
- . Matches a single character.
- [abc] matches a or B or z
- | separates strings
- ^ anchors the match from the start.
- "." Can be used to match any single character. "|" can be used to match either of the two strings
- REGEXP can be used to match the input characters with the database.
Example: The following statement retrieves all rows where column employee_name contains the text 1000 (example salary):
- Select employee_name
- From employee
- Where employee_name REGEXP '1000'
- ORDER by employee_name
In MySQL, regular expressions are used in queries for searching a pattern in a string. Example: The following statement retrieves all rows where column employee_name contains the text 1000 (example salary):
|