Database Reference
In-Depth Information
mysql> SELECT CHARSET(BINARY _latin1 'my string');
+-------------------------------------+
| CHARSET(BINARY _latin1 'my string') |
+-------------------------------------+
| binary |
+-------------------------------------+
5.6. Converting the Lettercase of a String
Problem
You want to convert a string to uppercase or lowercase.
Solution
Use the UPPER() or LOWER() function. If they don't work, you're probably trying to
convert a binary string. Convert it to a nonbinary string that has a character set and
collation and is subject to case mapping.
Discussion
The UPPER() and LOWER() functions convert the lettercase of a string:
mysql> SELECT thing, UPPER(thing), LOWER(thing) FROM limbs;
+--------------+--------------+--------------+
| thing | UPPER(thing) | LOWER(thing) |
+--------------+--------------+--------------+
| human | HUMAN | human |
| insect | INSECT | insect |
| squid | SQUID | squid |
| fish | FISH | fish |
| centipede | CENTIPEDE | centipede |
| table | TABLE | table |
| armchair | ARMCHAIR | armchair |
| phonograph | PHONOGRAPH | phonograph |
| tripod | TRIPOD | tripod |
| Peg Leg Pete | PEG LEG PETE | peg leg pete |
| space alien | SPACE ALIEN | space alien |
+--------------+--------------+--------------+
But some strings are “stubborn” and resist lettercase conversion:
mysql> CREATE TABLE t (b BLOB) SELECT 'aBcD' AS b;
mysql> SELECT b, UPPER(b), LOWER(b) FROM t;
+------+----------+----------+
| b | UPPER(b) | LOWER(b) |
+------+----------+----------+
| aBcD | aBcD | aBcD |
+------+----------+----------+
Search WWH ::




Custom Search