This MariaDB tutorial explains how to use the MariaDB REPLACE function with syntax and examples.
The MariaDB REPLACE function replaces all occurrences of a specified string.
The syntax for the REPLACE function in MariaDB is:
REPLACE( string, from_substring, to_substring )
The source string.
The substring to find. All occurrences of from_substring found within string are replaced with to_substring.
The replacement substring. All occurrences of from_substring found within string are replaced with to_substring.
The REPLACE function can be used in the following versions of MariaDB:
Let's look at some MariaDB REPLACE function examples and explore how to use the REPLACE function in MariaDB.
For example:
SELECT REPLACE('AODBA.com', '.com', ' knows MariaDB!');
Output: 'AODBA knows MariaDB!'
SELECT REPLACE('AODBA.com', '.COM', ' knows MariaDB!');
Output: 'AODBA.com'
SELECT REPLACE('abc abc', 'b', 'X');
Output: 'aXc aXc'
SELECT REPLACE('abc abc', 'B', 'X');
Output: 'abc abc'
SELECT REPLACE('12345 12345', 1, 9);
Output: '92345 92345'