How to find all upper case strings in a MySQL table?

廉价感情. 提交于 2019-12-02 21:06:26

If your collation is case insensitive then you need to use a BINARY comparison:

SELECT *
FROM yourtable
WHERE Name = BINARY UPPER(Name)

See it working online: sqlfiddle

You just use the UPPER() function on the Name field and compare the results with the original value of Name:

select Name from Table where Name = UPPER(Name)

This way

UPPER(Name)   ||  Name
---------------------------------------
JOHN          !=  John
MARY          ==  MARY
KIN           !=  Kin
TED           ==  TED

only the rows you need will be returned.

As @mdoyle commented here, you should define the column with the right collation (case sensitive), otherwise as others did answer you need the BINARY operator to compare case insensitive columns.

Try this:

select name from table where name=upper(name);

Try this:

SELECT Name
FROM   table
WHERE  Name COLLATE latin1_general_cs LIKE UPPER(Name)
;
Kedar Acharekar

Use Below:

SELECT name FROM table WHERE name = BINARY UPPER(column_name);

This will also return numeric values, but that doesnt look to be an issue for your column name.

SELECT * FROM names WHERE 

ASCII(name) = ASCII(Upper(name))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!