开发者

concat_ws and lowercase and uppercase

开发者 https://www.devze.com 2022-12-14 10:53 出处:网络
I am using concat_ws to search a table (code given below). SELECT * FROM customers WHERE CONCAT_WS(\'\',lastname,firstname) LIKE \'%$string%\'

I am using concat_ws to search a table (code given below).

SELECT * FROM customers WHERE CONCAT_WS('',lastname,firstname) LIKE '%$string%'

My problem is 开发者_开发百科that seperates uppercase and lowercase.

If I search AB I get 10 results BUT if I search ab I get 1 result.

Is there any way to get the same results, meaning not separate uppercase and lowercase?


Maybe try this:

SELECT * FROM customers WHERE LOWER(CONCAT_WS('',lastname,firstname)) LIKE '%$string%'

And search in lowercase ?


SELECT * FROM customers WHERE LOWER(CONCAT_WS('',lastname,firstname)) LIKE '%$string%'

The solution assumes, the $string variable is always lowercase.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号