Articles Cookbook
Back to list
Standard SQL

How to Convert a String to Lowercase in SQL

Database:

Operators:

LOWER

Problem:

You would like to convert a string to lowercase.

Example:

Our database has a table named product with data in the id and name columns.

idname
1Cobb Salad
2Pot roast
3Jerky
4BANANA SPLIT
5CORN bread
6chicken fried Steak

Notice that the naming styles are inconsistent for these products. Let’s display all product names in lowercase.

Solution 1:

SELECT LOWER(name)
FROM product;

Here’s the result:

name
cobb salad
pot roast
jerky
banana split
corn bread
chicken fried steak

Discussion:

Use the SQL LOWER() function if you want to convert a string column to lowercase. This function takes only one argument: the column whose values you want to lowercase.

This function is a good choice if your database is case sensitive and you want to select only records matching a particular string. You can first convert everything to lowercase and then find a match.

Recommended courses:

Recommended articles:

See also:

go to top