Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Replace Function In Sql in SQL

Replace Function In Sql in SQL

? REPLACE Function in SQL

The REPLACE() function in SQL is used to replace all occurrences of a substring within a string with another substring.


? Syntax:

REPLACE(string, from_substring, to_substring)
  • string: The original string.

  • from_substring: The substring you want to replace.

  • to_substring: The new substring you want to insert.


? Example 1: Basic Replacement

SELECT REPLACE('SQL is fun', 'fun', 'awesome') AS result;

? Output:

result
SQL is awesome

? Example 2: Remove characters (replace with empty string)

SELECT REPLACE('123-456-7890', '-', '') AS phone_number;

Output:

phone_number
1234567890

? Example 3: Case-sensitive

SELECT REPLACE('Hello HELLO Hello', 'Hello', 'Hi') AS result;

Output:

result
Hi HELLO Hi

Only replaces exact matches (case-sensitive).


? Supported in:

  • MySQL

  • PostgreSQL

  • SQL Server

  • Oracle


Would you like to see how to use REPLACE() in an UPDATE statement to modify table data?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql