Consider a table with data as below.
+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| ID | FIRSTNAME | LASTNAME |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| 1 | Brian | White || 2 | Sian | Greg || 3 | Harley | Jeo |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +
Now, let us use regular expression in MySQL to find out the data where the FIRSTNAME starts with the letter ‘B’
Query: SELECT * FROM EMP_DETAILS WHERE FIRSTNAME REGEXP '^B';Output:
+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| ID | FIRSTNAME | LASTNAME |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| 1 | Brian | White |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +
Below is an example of how to find records that end with the letter ‘o’
Query: SELECT * FROM EMP_DETAILS WHERE LASTNAME REGEXP 'o$';Output:
+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| ID | FIRSTNAME | LASTNAME |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +| 3 | Harley | Jeo |+ -- -- -- + -- -- -- -- -- -- + -- -- -- -- -- -- +
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.




















