Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-sonnet-20241022· AnthropicHugging Face LMArena Human Preference 140K

mysql: I use utfmb4 ci, but for a particular where clause I want to compare the column…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash’s answer.
  1. User

    mysql: I use utfmb4 ci, but for a particular where clause I want to compare the column to a string in an accent sensitive way (no need for case sensitivity)

  2. Claude Assistant

    For accent-sensitive but case-insensitive comparison in MySQL when your collation is utf8mb4_ci, you can use the COLLATE clause in your WHERE statement to temporarily use a different collation. The utf8mb4_as_ci collation would work for this - it's accent-sensitive but case-insensitive.

    Here's an example:

    SELECT * FROM table_name 
    WHERE column_name COLLATE utf8mb4_as_ci = 'value';
    

    If you need this for multiple comparisons, you could also write:

    SELECT * FROM table_name 
    WHERE (column_name COLLATE utf8mb4_as_ci = 'value1'
       OR column_name COLLATE utf8mb4_as_ci = 'value2');
    

    This way, only this specific comparison will be accent-sensitive, while the rest of your queries will continue using your default utf8mb4_ci collation.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.