区分大小写的列中不区分大小写的搜索(以及不区分大小写的顺序)

时间:2022-04-26 00:43:13

I have a case-sensitive colume(utf8_bin collation). I need to search a string case-insensitively and order the results case-insensitively.

我有一个区分大小写的colume(utf8_bin collat​​ion)。我需要不区分大小写地搜索字符串,并且不区分大小写地排序结果。

Is have written this query.

已经写了这个查询。

SELECT customer_name 
   FROM customers
   WHERE CONVERT(customer_name USING UTF8) LIKE 'aB%' 
   ORDER BY CONVERT(customer_name USING UTF8) 
   LIMIT 0,10

Is this efficient? Or is there a better way to achieve this?

这有效吗?或者有更好的方法来实现这一目标吗?

1 个解决方案

#1


2  

What about converting in uppercase?

转换成大写怎么样?

SELECT customer_name 
   FROM customers
   WHERE UPPER(customer_name) LIKE 'AB%' 
   ORDER BY UPPER(customer_name) 
   LIMIT 0,10

#1


2  

What about converting in uppercase?

转换成大写怎么样?

SELECT customer_name 
   FROM customers
   WHERE UPPER(customer_name) LIKE 'AB%' 
   ORDER BY UPPER(customer_name) 
   LIMIT 0,10