Select ALL fields that contains only UPPERCASE letters

Viewed 37345

How do you select a field that contains only uppercase character in mysql or a field that doesn't contain any lower case character?

8 Answers
SELECT column_name FROM table WHERE column_name REGEXP BINARY '^[A-Z]+$'

Found this in the comments - it deserves a post of its own:

SELECT * FROM mytable WHERE BINARY mycolumn = BINARY UPPER(mycolumn);

The problem with WHERE UPPER(mycolumn) = mycolumn is the collation, and it depends on your table what you can use there.

Related