SQL > SQL String Functions > Replace Function

The Replace function in SQL is used to update the content of a string. The function call is REPLACE( ) for MySQL, Oracle, and SQL Server.

Syntax

The syntax of the Replace function is:

REPLACE (str1, str2, str3)

In str1, find where str2 occurs, and replace it with str3.

Example

We use the following table for our example.

Table Geography

Region_Name Store_Name
East Boston
East New York
West Los Angeles
West San Diego

If we apply the following Replace function:

SELECT REPLACE (Region_Name, 'ast', 'astern') REGION1
FROM Geography;

we get the following result:

REGION1
Eastern
Eastern
West
West

This page was last updated on October 12, 2024.




Copyright © 2026 1keydata.com All Rights Reserved Privacy Policy About Contact


AdBlock Detected!

Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.

AltStyle によって変換されたページ (->オリジナル) /