MySQL Capitalization Issue

Posted by hank, Sat Feb 24 13:07:00 UTC 2007

So, a problem with MySQL (in my opinion) is that it is not case sensitive by default for VARCHAR fields. That makes getting rid of crappy entries like ’ITALY’ a bother. I mean, sure, I could just post-process it with ruby (see titleize), but what’s the fun in that.


select distinct BINARY(lead_country) from countries;

Ah, finally recognizes that ITALY is not Italy. One is definitely uglier than the other one. Now for the change.


update countries set lead_country = 'Italy' where lead_country = "ITALY";

Much better.

Tags:

Comments

Have your say

A name is required. You may use Markdown in your comments.