How do you select a field that contains only uppercase character in mysql or a field that doesn't contain any lower case character?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
Try this -
This worked for me. It found all user emails with uppercase character:
Found this in the comments - it deserves a post of its own:
The problem with
WHERE UPPER(mycolumn) = mycolumn
is the collation, and it depends on your table what you can use there.You may want to use a case sensitive collation. I believe the default is case insensitive. Example:
Then:
If you don't want to use a case sensitive collation for the whole table, you can also use the
COLLATE
clause as @kchau suggested in the other answer.Let's try with a table using a case insensitive collation:
This won't work very well:
But we can use the
COLLATE
clause to collate the name field to a case sensitive collation:By using
REGEXP
: http://www.tech-recipes.com/rx/484/use-regular-expressions-in-mysql-select-statements/Use
[:upper:]
for uppercase letters.Basic eg.