简体   繁体   中英

MySql Query to Change a lower case to upper case

How to change all lower cases in a string to upper cases using MySql Query?

如果要更新:

UPDATE my_table SET my_column = UPPER(my_column)

Have a look at using UPPER

Returns the string str with all characters changed to uppercase according to the current character set mapping.

From the LINK

UCASE() is a synonym for UPPER().

Have a look at this example

SQL Fiddle DEMO

Here is an example of changing the table data

Use upper() or UCASE()

Example:

SELECT UCASE(columnName) FROM `table_name` 
SELECT UPPER(columnName) FROM `table_name`

Updation

UPDATE table_name SET field_name = UPPER(field_name)
UPDATE table_name SET field_name = UCASE(field_name)

You can use UPPER for this:

select upper(MyColumn) 
from MyTable

您可以使用此代码更改查询 SQL 的大写:

UPDATE penduduk SET dusun = UPPER(dusun);

For column updates on a table, it may depend on if your collation is case insensitive . If that is the case then try using Binary comparison :

update table_name
set column_name = BINARY UPPER(column_name)

Otherwise this should work,

update table_name
set column_name = UPPER(column_name)

If you are using MYSQL Workbench and have safe updates on then try:

update table_name
set column_name = BINARY UPPER(column_name)
WHERE  column_name = BINARY LOWER(column_name)

If you are using phpMyAdmin goes to SQL then type

UPDATE `tableName` SET `ColumnName`=UPPER(`ColumnName`)

Eg:

UPDATE`cars` SET `Model`=UPPER(`Model`)

then save it.

PS: If you are a learner, follow this TIP

Before you type the tablename , you need to type this sign ` before and after, as well as when you type the column name.

UPDATE TableName SET ColumnName = UPPER(ColumnName)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM