5

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?

Lizard
  • 41,806
  • 38
  • 103
  • 165
Haroldo
  • 34,957
  • 46
  • 126
  • 166
  • 2
    Possible duplicate http://stackoverflow.com/questions/3028839/not-case-sensitive-query-in-mysql – aioobe Jun 14 '10 at 08:15

1 Answers1

7

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.

aioobe
  • 399,198
  • 105
  • 792
  • 807