SQL UPPER and LOWER Functions: Change Case (All Databases)
SQL UPPER and LOWER functions to convert string case. Identical syntax across MySQL, PostgreSQL, SQL Server, Oracle with case-insensitive search tips.
Overview
UPPER converts a string to uppercase, LOWER to lowercase. These functions are essential for case-insensitive comparisons and data normalization.
All Databases
-- Convert to uppercase:
SELECT UPPER('hello world'); -- 'HELLO WORLD'
-- Convert to lowercase:
SELECT LOWER('HELLO WORLD'); -- 'hello world'
-- Case-insensitive search:
SELECT * FROM users
WHERE LOWER(email) = LOWER('John@Example.COM');
-- Normalize data on insert:
INSERT INTO users (email, name)
VALUES (LOWER(TRIM(' John@Example.COM ')), 'John');
-- Title case (capitalize first letter):
-- MySQL:
SELECT CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTRING(name, 2))) FROM users;
-- PostgreSQL:
SELECT INITCAP('hello world'); -- 'Hello World'
-- Oracle:
SELECT INITCAP('hello world') FROM DUAL; -- 'Hello World'
Skip the Syntax Lookup
Instead of memorizing UPPER / LOWER syntax for each database, describe what you need in plain English and let AI2SQL generate the correct query.
No credit card required
Frequently Asked Questions
How do I convert text to uppercase in SQL?
Use UPPER(string). To convert to lowercase, use LOWER(string). Both work identically in MySQL, PostgreSQL, SQL Server, and Oracle.
How do I do a case-insensitive search in SQL?
Use LOWER(column) = LOWER('value') or UPPER on both sides. In MySQL, comparisons are case-insensitive by default with utf8 collation.
Can AI2SQL handle case conversion?
Yes. AI2SQL generates queries with proper case handling. Just describe what you need and it applies UPPER/LOWER as needed.