MySQL uses the REGEXP operator for regular expression matching.

Examples of operation

Find all data starting with ‘st’ in the name field:

SELECT name FROM person_tbl WHERE name REGEXP '^st';
Copy the code

Find all data ending in ‘OK’ in the name field:

SELECT name FROM person_tbl WHERE name REGEXP 'ok$';
Copy the code

Find all data in the name field that contains the ‘mar’ string:

SELECT name FROM person_tbl WHERE name REGEXP 'mar';
Copy the code

Find all data in the name field that begins with a vowel character or ends with an ‘OK’ string:

SELECT name FROM person_tbl WHERE name REGEXP '^[aeiou]|ok$';
Copy the code

Check out the MYSQL column

Ok, that’s it for today, people like, bookmark, comment, see you next time ~~