case-insensitive search of MySQL?
For my site search, what is the most efficient way of to query my db for a word/phrase regardless of case?
If your database / table is not set up with a case-insensitive collate you need to append something like COLLATE utf8_general_ci
to your query. (The _ci
suffix stands for case insensitive.)
Have a look at the documentation: 9.1.7.1. Using COLLATE in SQL Statements :
With the COLLATE clause, you can override whatever the default collation is for a comparison. COLLATE may be used in various parts of SQL statements.
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.