Operating System - HP-UX
1753300 Members
7142 Online
108792 Solutions
New Discussion юеВ

Re: remove word from column

 
SOLVED
Go to solution
Eric Antunes
Honored Contributor

Re: remove word from column

Hi,

Complementing Patty answer, you should see what you are going to update before (I strongly recomend it) doing it:

select address_column, replace( address_column,'speed test',null) address_column_replaced
from table_name
where address_column != replace( address_column,'speed test',null);

And after above query results were verified, do the update:

update table_name
set address_column = replace( address_column,'speed test',null)
where address_column != replace( address_column,'speed test',null);

Best Regards,

Eric Antunes

Each and every day is a good day to learn.
Eric Antunes
Honored Contributor

Re: remove word from column

Correction:

Complementing Patti's answer...
Each and every day is a good day to learn.
Ratzie
Super Advisor

Re: remove word from column

I am trying to get a script to work.
I have the list of tn's that I used when I appended that field but now I can not seem to get it to work.

#!/usr/bin/sh
cat test3|while read i
do echo $i
sqlplus -s admin/admin <update cust_table
set customer = replace (customer,'Speed Trail','');
where tn = ($i);
commit;
quit

EOF
done
Patti Johnson
Respected Contributor

Re: remove word from column

What is the error that you are getting?
Also is tn a number? If not you will need to use quotes around '$i'.

You could use
update cust_table
set customer =
replace (customer,'Speed Trail','')
where customer like '%Speed Trail%'
/

( actually when I cut/pasted your sql I noticed the extra ; at the end of the replace)

You could use
update cust_table
set customer =
replace (customer,'Speed Trail',''); <<---
where customer like '%Speed Trail%'



Ratzie
Super Advisor

Re: remove word from column

Greatly appreciated!!
Thanks Patty