drop table t1;
create table t1 ( id varchar(200)) default charset=utf8 ;
insert into t1 values ('中文'),('sdalfkj');
1)用正式表達式 regexp "[u0391-uFFE5]"
[email protected] : test 21:55:33> select id ,id regexp "[u0391-uFFE5][u0391-uFFE5]" from t1;
+---------+--------------------------------------------+
| id | id regexp "[u0391-uFFE5][u0391-uFFE5]" |
+---------+--------------------------------------------+
| 中文 | 0 |
| sdalfkj | 1 |
+---------+--------------------------------------------+
2 rows in set (0.01 sec)
2) 用length和char_length
[email protected] : test 23:33:13> select id,length(id),char_length(id) from t1;
+---------+------------+-----------------+
| id | length(id) | char_length(id) |
+---------+------------+-----------------+
| 中文 | 6 | 2 |
| sdalfkj | 7 | 7 |
+---------+------------+-----------------+
2 rows in set (0.00 sec)