REPLACE(x,y,z) 

REPLACE(x,y,z) is a string function that replaces the character string y in the character string x with the character string z.

 

Result of the REPLACE(x,y,z) function

REPLACE(x,y)

The character string y in x is deleted

x is NULL value

NULL value

y is NULL value

x remains unchanged

z is NULL value

The character string y in x is deleted

 

Model table: hotel

The abbreviated street notation is to be written out in full for the sake of uniformity.

SELECT hno, zip, city, REPLACE (address, 'tr.', 'treet') address
FROM hotel WHERE address = '%tr'

HNO

ZIP

CITY

ADDRESS

40

21109

Los Angeles

155 Beechwood Street

50

20097

Los Angeles

1499 Grove Street

80

20251

Los Angeles

12 Barnard Street

 

See also:

TRANSLATE(x,y,z)