【发布时间】:2015-01-20 07:28:16
【问题描述】:
我有一个如下结构的表格(真实数据替换为虚拟数据):
tableName
+-----------+----------------+
| code | description |
+-----------+----------------+
| A | text here |
| b | blah blah |
| c | sdfsdfsdfsdf |
| d | sdfsfkaljdaklj |
| e | asdkjasdlkjasd |
| f | adskljalkdj |
| g | asdjalkd |
| h | askdjavsd |
+-----------+----------------+
我正在尝试执行以下命令:
SELECT * FROM tableName WHERE description LIKE '__[aeiou]%';
我希望这个 select 语句从表中返回描述中第三个字符是 a、e、i、o 或 u 的所有结果。
但是,关于查询我得到 0 个结果。我知道表中存在与此模式匹配的有效结果(第 3 个字符是 a、e、i、o 或 u)。
我的查询有什么问题?
【问题讨论】:
-
我不认为 mysql LIKE 接受范围 [] 所以它将它解释为以 [. 开头的文字字符串
-
来自您的链接
The other type of pattern matching provided by MySQL uses extended regular expressions. When you test for a match for this type of pattern, use the REGEXP and NOT REGEXP operators
标签: mysql sql wildcard sql-like