Update all values of a column to lowercase

Mysql

Mysql Problem Overview


Lets say I have something like this

uid    tag
1      HeLLo
2      heLLO
3      HELLO
4      hello

How can I update all values in the "tag" column to:

uid    tag
1      hello 
2      hello 
3      hello 
4      hello 

using MySQL?

Mysql Solutions


Solution 1 - Mysql

Solution 2 - Mysql

LOWER()

update table set tag = LOWER(tag)

Solution 3 - Mysql

Version for case-insensitive matching and including a "WHERE" clause if you don't want to update the entire column:

UPDATE table 
SET tag = LOWER(tag)
WHERE LOWER(tag) != tag
COLLATE Latin1_General_CS_AS

The COLLATE line will make it work if your database uses case insensitive matching, as mine does.

Solution 4 - Mysql

Try this:

update `table` set `column_name` = LOWER(column_name without quotation)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdam RamadhanView Question on Stackoverflow
Solution 1 - MysqlRippoView Answer on Stackoverflow
Solution 2 - MysqlShakti SinghView Answer on Stackoverflow
Solution 3 - MysqlSusieView Answer on Stackoverflow
Solution 4 - MysqlAnjani BarnwalView Answer on Stackoverflow