MariaDB: REPLACE Function
This MariaDB tutorial explains how to use the MariaDB REPLACE function with syntax and examples.
Description
The MariaDB REPLACE function replaces all occurrences of a specified string.
Syntax
The syntax for the REPLACE function in MariaDB is:
REPLACE( string, from_substring, to_substring )
Parameters or Arguments
- string
- The source string.
- from_substring
- The substring to find. All occurrences of from_substring found within string are replaced with to_substring.
- to_substring
- The replacement substring. All occurrences of from_substring found within string are replaced with to_substring.
Note
- The REPLACE function performs a case-sensitive replacement.
Applies To
The REPLACE function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB REPLACE function examples and explore how to use the REPLACE function in MariaDB.
For example:
SELECT REPLACE('TechOnTheNet.com', '.com', ' knows MariaDB!'); Result: 'TechOnTheNet knows MariaDB!' SELECT REPLACE('TechOnTheNet.com', '.COM', ' knows MariaDB!'); Result: 'TechOnTheNet.com' SELECT REPLACE('abc abc', 'b', 'X'); Result: 'aXc aXc' SELECT REPLACE('abc abc', 'B', 'X'); Result: 'abc abc' SELECT REPLACE('12345 12345', 1, 9); Result: '92345 92345'
Advertisements