Skip to main content
SQL โ€ข LESSON 139

REPLACE

How can we remove dashes from phone numbers?

Advancedโฑ 3 Minutesโญ 1520 XP
๐Ÿค” THE QUESTION

How can we remove dashes from phone numbers?

๐Ÿ’ก WHAT IS IT?

REPLACE(str, search, replacement) substitutes all occurrences of a substring with a target string.

๐ŸŽฏ WHAT IS IT USED FOR?

Phone number normalization, replacing special characters, scrubbing delimiters.

๐Ÿ’ป EXAMPLE
SELECT
REPLACE(phone, '-', '') AS normalized_phone
FROM employees;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for REPLACE.

  • โœ“ REPLACE() function
  • โœ“ Character scrubbing
  • โœ“ Phone normalization
  • โœ“ String sanitization