sqlcmd.net validated sql reference
beginner string-processing MySQL MariaDB SQL Server PostgreSQL SQLite

Change Text Case With UPPER And LOWER

Convert string values to all uppercase or all lowercase using `UPPER` and `LOWER`.

Docker-validated Not currently validation-green

Display names in both uppercase and lowercase

The stored values are unchanged — UPPER and LOWER only affect the query output. Use them in a WHERE clause like WHERE LOWER(name) = 'alice smith' for case-insensitive lookups that work regardless of how data was stored.

Rows loaded before the example query runs.
Setup
CREATE TABLE users (id INT, name VARCHAR(50));

INSERT INTO
  users (id, name)
VALUES
  (1, 'alice smith'),
  (2, 'BOB JONES');
Shared across supported engines.
SQL
SELECT
  id,
  UPPER(name) AS upper_name,
  LOWER(name) AS lower_name
FROM
  users
ORDER BY
  id;
Returned rows for the shared example.
idupper_namelower_name
1ALICE SMITHalice smith
2BOB JONESbob jones

Output is identical across all engines.

Where this command helps.

  • normalizing string case before comparison or display
  • performing case-insensitive lookups on inconsistently stored data

What the command is doing.

UPPER(string) returns the string with all characters converted to uppercase. LOWER(string) does the same for lowercase. These functions are most useful for normalizing strings before comparisons — for example, LOWER(email) = LOWER(input) performs a case-insensitive match without relying on collation settings.