To make a string comparison not case sensitive, convert both strings to the same lettercase using UPPER( ) or : String Compare « String « SQL / MySQL






To make a string comparison not case sensitive, convert both strings to the same lettercase using UPPER( ) or

      
LOWER( ):
mysql>
mysql> SELECT UPPER('A'), UPPER('b'), UPPER('A') < UPPER('b');
+------------+------------+-------------------------+
| UPPER('A') | UPPER('b') | UPPER('A') < UPPER('b') |
+------------+------------+-------------------------+
| A          | B          |                       1 |
+------------+------------+-------------------------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> SELECT LOWER('A'), LOWER('b'), LOWER('A') < LOWER('b');
+------------+------------+-------------------------+
| LOWER('A') | LOWER('b') | LOWER('A') < LOWER('b') |
+------------+------------+-------------------------+
| a          | b          |                       1 |
+------------+------------+-------------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.Compare String in where clause
2.String comparisons are performed from left to right, one character at a time:
3.The two strings '4200' and '4200.0' are not the same:
4.Case-insensitive nature of string comparisons:
5.String comparisons in MySQL are not case sensitive by default:
6.To make a string comparison case sensitive, cast (convert) one of the strings to binary form by using the BINA
7.NULL values fail comparisons both with < and with >=