you are at Encyclopedia of SQL >> REPLACE
REPLACE(str1,str2,str3)
This function returns a string or an array with all occurrences of string str2 in searched string
str2 replaced with the given replace value str3.
Syntax
SELECT REPLACE(`column_name`,`str2`,`str3`)
FROM `table_name`
WHERE `column_name`
Example
Display name and surname but instead of name Michał display Michael
name | surname | age |
Paweł | Kowalski | 3 |
Piotr | Janik | 7 |
Michał | Nowak | 13 |
query
SELECT REPLACE(`name`,'Michał','Michael'),`surname`
FROM `people`
result
REPLACE(`name`,'Michał','Michael') | surname |
Paweł | Kowalski |
Piotr | Janik |
Michał | Nowak |
[ wróć na górę strony ]