[Level 2] MySQL Query with Regular Expression.

If you  want to let your query more powerful,
you can use regular expression to enhance your SQL query.

mysql> create table testRegExp (name varchar(32));
mysql> insert into testRegExp values('Stanley'),('Christy'),('Joseph'),('Chantelle');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from testRegExp where name regexp '^(S|C)';
+-----------+
| name      |
+-----------+
| Stanley   |
| Christy   |
| Chantelle |
+-----------+
3 rows in set (0.00 sec)

mysql> 


Ref:
http://dev.mysql.com/doc/refman/5.1/en/regexp.html

Wish this helps.

regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 1] Rar tool for Solaris.

[Level 2] iif in Python