[SQL]Multiple REPLACE on a column

Aaron5 -  
ludo6577 Posted messages 9 Registration date   Status Membre Last intervention   -
Hello everyone,

I would like to know if it is possible to replace several strings in the same column using REPLACE.

For example, let's imagine a column where I store the polite form associated with my users with:
- 1 corresponds to Mr.
- 2 corresponds to Mrs.
- 3 corresponds to Miss.

If I do:
Code:
Select all - View in a separate window
 SELECT REPLACE(user.title,'1','Monsieur') FROM TABLE 


it correctly replaces the 1 with Monsieur, but is there a way to replace the 2 and 3 at the same time?

1 réponse

ludo6577 Posted messages 9 Registration date   Status Membre Last intervention   13
 
Topic already exists
https://forums.commentcamarche.net/forum/affich-4939138-sql-server-fonction-replace

But since I'm nice we can do it by nesting the REPLACE:
SELECT REPLACE(REPLACE(REPLACE(user.title, "1", "Mr"), "2", "Mrs"), "3", "Ms") FROM Table
0