Introduction
UPPER and LOWER help change text to all uppercase or all lowercase letters. This makes text easier to compare or display consistently.
UPPER(text) LOWER(text)
SELECT UPPER('hello world');
SELECT LOWER('HELLO WORLD');
SELECT UPPER(name) FROM employees;
SELECT LOWER(city) FROM customers;
CREATE TABLE users (id INT, username VARCHAR(20)); INSERT INTO users VALUES (1, 'Alice'), (2, 'Bob'), (3, 'CHARLIE'); SELECT id, UPPER(username) AS upper_name, LOWER(username) AS lower_name FROM users;
UPPER('hello') return?name to lowercase in a SELECT query?products with a column category containing values 'Books', 'electronics', 'TOYS', what will the query SELECT DISTINCT UPPER(category) FROM products; return?SELECT LOWER('MySQL') FROM dual. It returns an error. What is the likely cause?users table whose email ends with '@example.com', ignoring case differences. Which query correctly uses UPPER or LOWER to achieve this?Pass the test and this pattern moves unknown