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
  • 43,732
  • 39
  • 106
  • 167
Haroldo
  • 36,607
  • 46
  • 127
  • 169
  • 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
  • 413,195
  • 112
  • 811
  • 826