MySQL正则表达式查询不区分大小写 [英] MySQL regex query case insensitive

查看:238
本文介绍了MySQL正则表达式查询不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表格中,我有名字和姓氏.很少有名字是大写(ABRAHAM),很少有名字是小写(abraham),很少有名字是以ucword开头的字符(Abraham).

In my table I have firstname and last name. Few names are upper case ( ABRAHAM ), few names are lower case (abraham), few names are character starting with ucword (Abraham).

因此,当我使用REGEXP'^ [abc]'执行where条件时,没有得到正确的记录.如何将名称更改为小写并使用SELECT QUERY.

So when i am doing the where condition using REGEXP '^[abc]', I am not getting proper records. How to change the names to lower case and use SELECT QUERY.

SELECT * FROM `test_tbl` WHERE cus_name REGEXP '^[abc]';

这是我的查询,如果记录为小写,但记录为中间,我的所有cus名称都不为小写,所有名称都类似于ucword,则可以正常工作.

This is my query, works fine if the records are lower case, but my records are intermediate ,my all cus name are not lower case , all the names are like ucword.

因此对于上述查询,无法获得正确的记录显示.

So for this above query am not getting proper records display.

推荐答案

我认为您应该查询数据库,以确保名称被降低,假设该名称是您希望找出的名称,并且在应用程序中, ve像'abraham'一样降低了它,现在您的查询应该像这样:

I think you should query your database making sure that the names are lowered, suppose that name is the name you whish to find out, and in your application you've lowered it like 'abraham', now your query should be like this:

SELECT * FROM `test_tbl` WHERE LOWER(cus_name) = name

由于我不知道您使用哪种语言,所以我只是放置了名称,但请确保将其降低,然后您应该检索亚伯拉罕,亚伯拉罕或任何名称的变体!

Since i dont know what language you use, I've just placed name, but make sure that this is lowered and you should retrieve Abraham, ABRAHAM or any variation of the name!

希望有帮助!

这篇关于MySQL正则表达式查询不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆