本文介绍了区分大小写RLIKE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

像这样考虑一个表datatbl:

+----------+
| strfield |
+----------+
|    abcde |
|    fgHIJ |
|    KLmno |
+----------+

我想写一个类似这样的查询:

I want to write a query something like this:

select * from datatbl where strfield rlike '[a-z]*';

与在非SQL正则表达式中一样,我想返回带有abcde的行,但不返回带有大写字母的行.我似乎找不到一种简单的方法来执行此操作.我想念一些愚蠢的东西吗?

As in a non-SQL regex, I'd like to return the row w/ abcde, but not the rows w/ capitals. I cannot seem to find an easy way to do this. Am I missing something stupid?

谢谢,乔

推荐答案

MySQL REGEXP/RLIKE很烂-您需要将数据强制转换为BINARY以便区分大小写:

The MySQL REGEXP/RLIKE sucks for this - you need to cast the data as BINARY for case sensitive searching:

SELECT *
  FROM datatbl
 WHERE CAST(strfield  AS BINARY) rlike '[a-z]*';

您会在对REGEXP/RLIKE的评论中发现该问题文档.

这篇关于区分大小写RLIKE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 23:40