
For an instructor lead, in-depth look at learning SQL click below.
In SQL programming, converting strings to either uppercase or lowercase can be achieved using in-built functions designed for this purpose. This conversion can be handy when performing data cleaning, manipulation and comparison tasks. In this blog post, we’re going to explore two key SQL functions: UPPER() and LOWER().
1. The UPPER() Function
The UPPER() function in SQL is used to convert all letters in a specified string to uppercase. Here’s the simple syntax:
|
1 2 3 |
UPPER(column_name) |
Let’s look at a practical example:
|
1 2 3 4 |
SELECT UPPER(CustomerName) AS UpperCaseCustomerName FROM Customers; |
In the above SQL query, the UPPER() function will convert all customer names in the “CustomerName” column to uppercase, and the alias “UpperCaseCustomerName” will be used to display the resultant column.
2. The LOWER() Function
Similarly, SQL’s LOWER() function is used to convert all text in a specified string to lowercase. Here is its syntax:
|
1 2 3 |
LOWER(column_name) |
And here’s how to use it:
|
1 2 3 4 |
SELECT LOWER(CustomerName) AS LowerCaseCustomerName FROM Customers; |
The LOWER() function here will change all customer names in the “CustomerName” column to lowercase, with the alias “LowerCaseCustomerName” being used to display the column’s output.
Conclusion
As a SQL programmer, understanding the use of string functions like UPPER() and LOWER() can significantly speed up your data manipulation and comparison tasks. Remember, these functions can be used on any text column in your database. Happy coding!
