Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Replace part of a text string using sql

Re: Replace part of a text string using sql

From: NinjaToy <LCIYQBBEQVFA_at_spammotel.com>
Date: Fri, 29 Nov 2002 14:10:51 +0000
Message-ID: <3DE7756A.DB87E701@spammotel.com>


Hows this for doing your work for you.

try
update user set email = replace (email, 'com', 'co.uk') where username like 'J%';

or this one which replaces everything after the @

update user set email =
substr(email, 1, instr(email, '@') - 1) || REPLACE(substr(email, instr(email, '@'), 100), '.com', '.co.uk') where
username like 'J%';

John Guthrie wrote:

> Hi All,
>
> I am trying to update part of a text string in a Varchar2 Column.
>
> replace:
> somebody_at_domainname.com
> with
> somebody_at_domainname.co.uk'
>
> I tried using the following sql:
>
> update user set email = replace ('domainname.com', 'com', 'co.uk') where
> username like 'J%';
>
> This produced the following result, it chopped of the "somebody" part:
> domainname.co.uk
>
> instead of returning
> somebody_at_domainname.co.uk
>
> Any ideas?
> Thanks for the help!
>
> Regards,
> John Guthrie

--
Suzuki SV650S - plop.  Gone.
Kwak ZX-6R J2 - hear the roar
 
Received on Fri Nov 29 2002 - 08:10:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US