MySQL/MariaDB How to convert character case - UPPER and LOWER functions

MySQL/MariaDB How to convert character case - UPPER and LOWER functions

Colleagues hello to all.

In today's article, we'll talk about how to convert strings to uppercase and lowercase in a MySQL and MariaDB database.

The case of characters in a database is very important and plays a big role when working with strings. For example, you may need to compare two strings case-insensitively. To solve this case of characters, you can use the built-in functions which are available in MySQL and MariaDB, it UPPER or LOWER. These functions convert the entire string in one operation.

 

Function UPPER.

Syntax function:

UPPER(string);

The function returns a string in which all characters are converted to uppercase. If NULL values ​​are passed to the function, then the function itself will return NULL.

 

Just an example of converting a string to uppercase.

sql> SELECT UPPER('hellow world');

convert character case


 

Function LOWER.

Syntax function:

LOWER(string);

The function returns a string in which all characters are converted to lower case. If NULL values ​​are passed to the function, then the function will return NULL.

 

Just an example of converting a string to lowercase.

sql> SELECT LOWER('HELLOW WORLD');

convert character case


 

Thank you all, I hope that my article helped you in some way.

 

SIMILAR ARTICLES

MySQL - Test Data Generation
MySQL - Test Data Generation
MYSQL
Read more
MySQL / MariaDB How to get the id of the last inserted record in a table - LAST_INSERT_ID
MySQL / MariaDB How to get the id of the last inserted record in a table - LAST_INSERT_ID
MYSQL
Read more
MySQL/MariaDB How to remove spaces in a string - TRIM function
MySQL/MariaDB How to remove spaces in a string - TRIM function
MYSQL
Read more