#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 11
7 min read

String Functions

Learn how to work with text - make it uppercase, lowercase, combine, and more!

What are String Functions?

String Function Examples
FunctionInputOutput
UPPER(name)johnJOHN
LOWER(name)MARYmary
LENGTH(name)Peter5
CONCAT(first, last)John + DoeJohn Doe
4 rows

String functions help you work with text. You can change text to uppercase, combine names, get text length, and more.

Simple analogy: Like text tools - make text LOUD (uppercase) or quiet (lowercase).

Common String Functions

String Function Examples
FunctionInputOutput
UPPER(name)johnJOHN
LOWER(name)MARYmary
LENGTH(name)Peter5
CONCAT(first, last)John + DoeJohn Doe
4 rows

UPPER - Make Text Uppercase

SELECT UPPER(name) FROM students;

Example:

  • Input: john
  • Output: JOHN

LOWER - Make Text Lowercase

SELECT LOWER(name) FROM students;

Example:

  • Input: MARY
  • Output: mary

CONCAT - Combine Text

SELECT CONCAT(first_name, ' ', last_name) AS full_name FROM users;

Example:

  • Input: John + Doe
  • Output: John Doe

LENGTH - Count Characters

SELECT name, LENGTH(name) AS name_length FROM students;

Example:

  • Input: John
  • Output: 4

SUBSTRING - Get Part of Text

SELECT SUBSTRING(email, 1, 4) AS email_start FROM users;

Example:

  • Input: john@email.com
  • Output: john

TRIM - Remove Spaces

SELECT TRIM(name) FROM students;

Example:

  • Input: " John "
  • Output: "John"

Real Examples

String Function Examples
FunctionInputOutput
UPPER(name)johnJOHN
LOWER(name)MARYmary
LENGTH(name)Peter5
CONCAT(first, last)John + DoeJohn Doe
4 rows

Example 1: Format Names

SELECT UPPER(first_name) AS first, LOWER(last_name) AS last FROM users;

Example 2: Create Email

SELECT name, LOWER(name) || '@company.com' AS email FROM employees;

Result: John becomes john@company.com

Example 3: Find Long Names

SELECT name FROM students WHERE LENGTH(name) > 10;

Shows students with names longer than 10 characters.

Summary

String Function Examples
FunctionInputOutput
UPPER(name)johnJOHN
LOWER(name)MARYmary
LENGTH(name)Peter5
CONCAT(first, last)John + DoeJohn Doe
4 rows

Common functions:

  • UPPER: Make uppercase
  • LOWER: Make lowercase
  • CONCAT: Combine text
  • LENGTH: Count characters
  • SUBSTRING: Get part
  • TRIM: Remove spaces

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses