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?
First, specify the table name that you want to change data in the UPDATE clause. Second, assign a new value for the column that you want to update. In case you want to update data in multiple columns, each column = value pair is separated by a comma (,). Third, specify which rows you want to update in the WHERE clause.
The LOWER() function converts a string to lower-case.
How to Convert Uppercase to Lowercase in SQL Server – LOWER() In SQL Server, you can convert any uppercase string to lowercase by using the LOWER() function. Simply provide the string as an argument when you call the function, and it will be returned in lowercase form.
To do a case-insensitive comparison, use the ILIKE keyword; e.g., column ILIKE 'aBc' and column ILIKE 'ABC' both return TRUE for 'abc' . In contrast, MySQL and MS SQL Server have case-insensitive behaviors by default. This means WHERE column = 'abc' returns TRUE for e.g., 'abc' , 'ABC' , or 'aBc' .
See http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_lower
UPDATE table_name SET tag = LOWER(tag)
LOWER()
update table set tag = LOWER(tag)
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.
Try this:
update `table` set `column_name` = LOWER(column_name without quotation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With