0

如何为以下场景编写带有正则表达式的查询。

id name
1  Müllere
2  Kees
3  Hernández
4  Björn

上面给出的是我的 MySQL 表。我想得到结果,名称包含重音字母且名称长度大于 5

4

3 回答 3

1

试试这个查询:

Select * from test where Length(name) > '5' and name REGEXP '[accentedcharacters]+';
于 2013-01-27T06:45:45.623 回答
0
WHERE length(name) > 5 and name REGEXP '[accentedcharacters]+' 

但是,我不确定重音字符的 mysql REGEXP

[1] http://dev.mysql.com/doc/refman/5.0/en/regexp.html

于 2013-01-27T06:34:57.267 回答
0
SELECT * FROM letters
+--------+
| letter |
+--------+
| '      |
| -      |
| a      |
| b      |
| c      |
| d      |
| e      |
| f      |
| g      |
| h      |
| i      |
| j      |
| k      |
| l      |
| m      |
| n      |
| o      |
| p      |
| q      |
| r      |
| s      |
| t      |
| u      |
| v      |
| w      |
| x      |
| y      |
| z      |
| å      |
| ä      |
| ö      |
| ÿ      |
+--------+

SELECT *
  FROM letters
 WHERE letter NOT REGEXP '[a-z\'|A-Z\-]';
+--------+
| letter |
+--------+
| å      |
| ä      |
| ö      |
| ÿ      |
+--------+
于 2013-01-27T18:55:23.767 回答