UPPER and LOWER
- SQL course
- Beginner
- Lesson 36/115
- 4 min
Convert text to upper or lower case.
UPPER and LOWER
UPPER converts text to uppercase, LOWER to lowercase. They are used for consistent search and comparison.
SELECT UPPER(name) AS upname FROM customers;This query converts customer names to uppercase.
UPPER(name) AS upname is selected from customers.
UPPER and LOWER — details
To bypass case-sensitive search you write WHERE UPPER(name) = 'AYSE'. Some databases offer ILIKE for case-insensitive matching.
Practice UPPER and LOWER
Select name in uppercase from customers.
Starter code
-- convert to uppercase
SELECT
FROM customersSample solution
SELECT UPPER(name) AS upname
FROM customersExpected output
upname AYŞE ALEX
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does UPPER do?
- Joins text
- Shortens text
- Converts text to uppercase Correct answer
- Deletes text
Explanation: UPPER converts text to uppercase.
2 Lowercase
SELECT ____(name) FROM customers;
SELECT LOWER(name) FROM customers;
Explanation: LOWER converts text to lowercase; it removes case differences in comparisons.
3 UPPER and LOWER: match the terms
| Term | Meaning |
|---|---|
UPPER |
uppercase |
LOWER |
lowercase |
LENGTH |
length |
TRIM |
trim |