LOWER function in SQL
The LOWER function in SQL is used to convert a string to lowercase. This function is useful when we need to perform case-insensitive comparisons or when we want to standardize text data.
SQL Syntax
LOWER(string)
- string: The string or column name that we want to convert to lowercase.
Example: Let's assume we have a table employees with the following data:
employee_id | first_name | last_name | department |
---|---|---|---|
1 | John | Doe | Sales |
2 | Jane | Smith | Marketing |
3 | Michael | O'Connor | HR |
4 | Sarah | O'Brien | IT |
5 | Laura | Wilson | Sales |
To convert the first_name column to lowercase:
SQL
SELECT employee_id, LOWER(first_name) AS first_name_lower, last_name, department
FROM employees;
FROM employees;
The result of the above query is shown below:
employee_id | first_name_lower | last_name | department |
---|---|---|---|
1 | john | Doe | Sales |
2 | jane | Smith | Marketing |
3 | michael | O'Connor | HR |
4 | sarah | O'Brien | IT |
5 | laura | Wilson | Sales |