Home > Software engineering >  Oracle sql replace particular special character with another
Oracle sql replace particular special character with another

Time:10-11

How can I replace a particular special character with another character?

Ex in same query I want to replace à with a and è with e. Both in same query.

If I use replace simply it doesn't work in sql developer.

CodePudding user response:

The REPLACE function can do this:

SELECT REPLACE( 'I want to replace à with a', 'à', 'a') FROM DUAL;

sql editor online

CodePudding user response:

Just try one of these ways:

  1. Solution 1:
SELECT REPLACE( REPLACE('I want to replace à with a and è with e', 'à', 'a'),'è', 'e') FROM DUAL;
  1. Solution 2:
SELECT translate('I want to replace à with a and è with e', 'àè', 'ae') FROM DUAL;

the second looks like better.

I use Oracle 12C release 2.

CodePudding user response:

You can achieve this using TRANSLATE() function: enter image description here

  • Related