Last chance! 50% off DataCamp Premium
Sale ends in
The `LOWER()` function in MySQL is used to convert all characters in a string to lowercase. It is particularly useful for case-insensitive comparisons and data normalization.
The `LOWER()` function is typically used when you need to ensure that string comparisons are case-insensitive or when you want to standardize text data to lowercase. It can be applied directly to string columns or expressions.
sql
LOWER(string)
In this syntax, `string` is the input text or column you want to convert to lowercase. Note that the `LOWER()` function does not modify the data in the database; it only returns the transformed result.
sql
SELECT LOWER('HELLO WORLD');
This example converts the string `'HELLO WORLD'` to `'hello world'`.
sql
SELECT LOWER(email)
FROM users;
Here, the `LOWER()` function is applied to the `email` column in the `users` table to return all email addresses in lowercase.
sql
SELECT *
FROM employees
WHERE LOWER(first_name) = 'john';
This example retrieves all records from the `employees` table where the `first_name` is `'John'`, `'john'`, or any other case variation of 'john'.