Haroldo
Haroldo

Reputation: 37377

case-insensitive search of MySQL?

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?

Upvotes: 5

Views: 791

Answers (1)

aioobe
aioobe

Reputation: 420991

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.

Upvotes: 7

Related Questions