If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Removing a word from data in a column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-04, 16:09
newbie2004 newbie2004 is offline
Registered User
 
Join Date: Apr 2004
Posts: 113
Removing a word from data in a column

Ok, I have a table that has a column called email.

Most of the email address have newbie@yahoo.com, however, some email addresses have mailto:newbie@yahoo.com.

How do I get rid of the mailto:?
Reply With Quote
  #2 (permalink)  
Old 09-13-04, 16:18
shoblock shoblock is offline
Registered User
 
Join Date: Apr 2004
Posts: 246
use ltrim
ltrim(col, 'mailto:')
__________________
Give a man a fish, you feed him for a day. Club him over the head with a fish, he'll leave you alone.
Reply With Quote
  #3 (permalink)  
Old 09-14-04, 10:29
newbie2004 newbie2004 is offline
Registered User
 
Join Date: Apr 2004
Posts: 113
Thank you shoblock.

I tried to use ltrim and I am getting no results but I know there is like 10,000 rows that needs to be fixed.

Here is my sql:

delete from unsub_final4
WHERE ltrim(email, 'mailto:')like 'mailto:%';
Reply With Quote
  #4 (permalink)  
Old 09-14-04, 10:32
gbrabham gbrabham is offline
Registered User
 
Join Date: Apr 2003
Location: Greenville, SC (USA)
Posts: 1,155
Use INSTR function

substr(col,instr(col,'mailto:',1)-1,numberofpositions)

HTH
Gregg
Reply With Quote
  #5 (permalink)  
Old 09-14-04, 10:39
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
Are you trying to delete those rows, or do you simply want to take away the mailto: part?

Because if you want to delete anything with a mailto, you dont need a trim or susbtr function - you would just do this:

Code:
delete from unsub_final4
where email like 'mailto:%'
BUT if you want to just remove the mailto: part and not delete the record, you need to use an update statement, and either the substr or ltrim (or replace or translate) functions.

Just wanted to clarify, because your delete statement is overkill right there.
__________________
Oracle OCPI (Certified Practicing Idiot)
Reply With Quote
  #6 (permalink)  
Old 09-14-04, 10:46
newbie2004 newbie2004 is offline
Registered User
 
Join Date: Apr 2004
Posts: 113
Thank you for your replies.

u are correct I just want to remove the mailto from the row.

So how about this:

update unsub_final4
set email = (select email from unsub_final4 WHERE ltrim(email, 'mailto:')like 'mailto:%');
Reply With Quote
  #7 (permalink)  
Old 09-14-04, 10:48
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,354
update unsub_final4
set email = replace(email,'mailto:',null);
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
  #8 (permalink)  
Old 09-14-04, 11:02
newbie2004 newbie2004 is offline
Registered User
 
Join Date: Apr 2004
Posts: 113
Thank you all!!

You are teaching me so much!!!
Reply With Quote
  #9 (permalink)  
Old 09-14-04, 14:06
WilliamR WilliamR is offline
Registered User
 
Join Date: Sep 2004
Location: London, UK
Posts: 564
LTRIM is not so useful here.
Code:
WITH testit AS
(
  SELECT 'mailto:tom@somewhere.net' AS col FROM dual
  UNION ALL
  SELECT 'tom@somewhere.net'       FROM dual
  UNION ALL
  SELECT 'tammi@somewhere.net'     FROM dual
  UNION ALL
  SELECT 'lamatamer@somewhere.net' FROM dual
)
SELECT col
     , LTRIM(col, 'mailto:') AS ltrimmed
FROM   testit;

COL                       LTRIMMED
------------------------- -------------------------
mailto:tom@somewhere.net  @somewhere.net
tom@somewhere.net         @somewhere.net
tammi@somewhere.net       @somewhere.net
lamatamer@somewhere.net   er@somewhere.net

4 rows selected.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On