Update all lowercase column values

Suppose I have something like this

uid tag 1 HeLLo 2 heLLO 3 HELLO 4 hello 

How to update all the values ​​in the tag column to:

 uid tag 1 hello 2 hello 3 hello 4 hello 

using MySQL?

+60
mysql
May 28 '11 at
source share
3 answers
+160
May 28 '11 at 9:53
source share
β€” -

LOWER ()

 update table set tag = LOWER(tag) 
+55
May 28 '11 at 9:53 a.m.
source share

Case insensitive version and inclusion of the WHERE clause if you do not want to update the entire column:

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

The COLLATE string will make it work if your database uses case insensitivity like mine.

+1
Oct 30 '17 at 22:23
source share



All Articles