1. 程式人生 > >6.06 判斷字符串是不是字母類型的

6.06 判斷字符串是不是字母類型的

rom nbsp mys war data tin 類型 concat emp

生成測試數據

create view v as
select ename as data from emp where deptno=10 union all
select concat(ename,‘, $‘,sal,‘.00‘) as data from emp where deptno=20 union all
select concat(ename,deptno) as data from emp where deptno=30;

mysql> select * from v;
+----------+
| data |
+----------+
| CLARK |
| KING |
| MILLER |
| ALLEN30 |
| WARD30 |
| MARTIN30 |
| BLAKE30 |
| TURNER30 |
| JAMES30 |
+----------+

解決方案:

mysql> select data from v
where data regexp ‘[^0-9a-zA-Z]‘ = 0 ;
+----------+
| data |
+----------+
| CLARK |
| KING |
| MILLER |
| ALLEN30 |
| WARD30 |
| MARTIN30 |
| BLAKE30 |
| TURNER30 |
| JAMES30 |
+----------+

6.06 判斷字符串是不是字母類型的