MySQL中不区分大小写的REPLACE? [英] Case-insensitive REPLACE in MySQL?
本文介绍了MySQL中不区分大小写的REPLACE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
除REPLACE
命令外,MySQL几乎在默认归类下运行所有字符串比较.我有不区分大小写的排序规则,需要运行不区分大小写的REPLACE
.有什么方法可以强制REPLACE
使用当前的排序规则,而不是始终执行区分大小写的比较?我愿意升级MySQL(当前运行5.1)以获取更多功能...
MySQL runs pretty much all string comparisons under the default collation... except the REPLACE
command. I have a case-insensitive collation and need to run a case-insensitive REPLACE
. Is there any way to force REPLACE
to use the current collation rather than always doing case-sensitive comparisons? I'm willing to upgrade my MySQL (currently running 5.1) to get added functionality...
mysql> charset utf8 collation utf8_unicode_ci;
Charset changed
mysql> select 'abc' like '%B%';
+------------------+
| 'abc' like '%B%' |
+------------------+
| 1 |
+------------------+
mysql> select replace('aAbBcC', 'a', 'f');
+-----------------------------+
| replace('aAbBcC', 'a', 'f') |
+-----------------------------+
| fAbBcC | <--- *NOT* 'ffbBcC'
+-----------------------------+
推荐答案
If replace(lower())
doesn't work, you'll need to create another function.
这篇关于MySQL中不区分大小写的REPLACE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文