The REPLACE function is used to change a string pattern with another string pattern in a given string expression.
The Replace function is available in both MSSQL and MySQL and it's functionality is also same except that MSSQL REPLACE function does case insensitive searches and replaces the string in any case whereas in MySQL it is case sensitive.
Here is the syntax and examples of both MSSQL and MySQL
REPLACE ( string_expression , string_pattern , string_replacement )
select replace('Win10 is latest version of win o/s','win','Windows') --------------------------------------------- Windows10 is latest version of Windows o/s
Notice that it has changed both Win10 and win o/s to Windows irrespective of case.
In MySQL also REPLACE function does the same job but it is case sensitive. See example below
REPLACE ( string_expression , str_sought , str_replacement )
mysql> select replace('Win10 is latest version of win o/s','win','Windows'); +---------------------------------------------------------------+ | replace('Win10 is latest version of win o/s','win','Windows') | +---------------------------------------------------------------+ | Win10 is latest version of Windows o/s | +---------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>
Notice that it has not changed Win10 because we passed lowercase 'win' as string pattern to be sought.
Back to Converting Functions from MSSQL to MySQL