Case-sensitive fields in MySQL

By default, MySQL treats all fields as case-insensitive. Here is how to change this behavior for some fields in a table or for a specific SELECT query:

for table fields:
If you set the field collation as utf8_binary instead of utf8_general_ci (or similar), that field will be case sensitive.

for select queries:
SELECT * FROM table_name WHERE BINARY field LIKE '%keyword%'

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
17 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.