Matches strings that begin with a vowel or end with er: : Begin With « Regular Expression « SQL / MySQL






Matches strings that begin with a vowel or end with er:

      
mysql>
mysql> CREATE TABLE mytable
    -> (
    ->  name    VARCHAR(20)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO mytable (name)
    ->  VALUES
    ->          ('copper'),
    ->          ('gold'),
    ->          ('iron'),
    ->          ('lead'),
    ->          ('mercury'),
    ->          ('platinum'),
    ->          ('silver'),
    ->          ('tin')
    -> ;
Query OK, 8 rows affected (0.00 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql>
mysql> SELECT * FROM mytable;
+----------+
| name     |
+----------+
| copper   |
| gold     |
| iron     |
| lead     |
| mercury  |
| platinum |
| silver   |
| tin      |
+----------+
8 rows in set (0.00 sec)

mysql>
mysql>
mysql> SELECT name FROM mytable WHERE name REGEXP '^[aeiou]|er$';
+--------+
| name   |
+--------+
| copper |
| iron   |
| silver |
+--------+
3 rows in set (0.00 sec)

mysql>
mysql> drop table mytable;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
  








Related examples in the same category

1.The caret (^) anchors the start, and the dollar sign ($) the end;
2.Pattern Matching: beginning with 'b'
3.String begins with
4.Pattern match: string begin with a certain letter
5.Pattern match: string begin and end
6.Show records where the name begins with a "B"
7.Show records where the name begins with a "B" or "C"
8.Strings that begin with a particular substring:
9.Matches where a is the first character