简体   繁体   中英

remove case sensitive in mysql search

I am write a query for search like:

SELECT * from page where (UPPER(page_title) LIKE 'PRIYA%');

But in my database i have a multiple result of priya like Priya_patel , Priya_Patel , Priya_d but the result was empty for this query.

My data in page_title field is:

Priya_patel, Priya_Patel,Priya_d_patel,Priya_yahoo,Priya_Mansi

For the table field " page_title " select COLLATION to ' utf8_unicode_ci ' or to some which is having _ci as suffix in it.

ci in '_ci' stands for Case Insensitive.

Then you execute the following query

SELECT * from page where page_title LIKE 'PRIYA%';

or

 SELECT * from page where page_title LIKE 'priya%';

or whatever ....

Your query is perfectly working. Problem is somewhere else.

SELECT * from page where (UPPER(page_title) LIKE 'PRIYA%');

Check DEMO

Your query is working correctly,

SELECT * FROM toto WHERE (UPPER( name ) LIKE  'PRIYA%')

also you can try like this to get the case insensitive result,

SELECT * FROM page WHERE LOWER(  `page_title` ) LIKE LOWER(  "PRIYA%" )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM