Simple Methods to Find Rows With Uppercase Letters in MySQL With Examples

There are different methods to find rows containing uppercase letters in MySQL. They all get done the job. In this MySQL tutorial we will understand the most popular ways for finding rows that contain uppercase letters in MySQL.

#1 Comparing The LOWER() Case Variant String

The first way of doing it below shows us we can do it by the comparing the lower() case variant string and get easily the job done. We can find out Rows with uppercase letters by using the “LOWER()” function. Here is how to do it.

SELECT c1 FROM t1
WHERE CAST(LOWER(c1) AS BINARY) <> CAST(c1 AS BINARY);

#2 Comparing The Actual Characters

You should understand that we can always find uppercase letters by comparing the characters that we have already stored. So for that, we will use “REGEXP” operator for comparing values with the patterns that will have uppercase letters in them. Please see below in the example that explains how we can achieve that:

SELECT c1 FROM t1
WHERE CAST(c1 AS BINARY) REGEXP CAST('[ABCDEFGHIJKLMNOPQRSTUVWXYZ]' AS BINARY);

#3 By Comparing The Range of Characters

So in this example you will notice we will use “REGEXP” once again to compare the range of characters that we have already have. The range of characters will have uppercase characters:

SELECT c1 FROM t1
WHERE CAST(c1 AS BINARY) REGEXP CAST('[A-Z]' AS BINARY);

So these are the simple ways that will help you find the uppercase letters with very simple examples. Still if you have any difficulties feel free to leave a comment. We will be happy to address that.