-
update statement problem
Hi, I need to replace all occurences of ".abc" to ".efgh" in a column. The period in the column is not actually at the same location for each row. I used the "like" clause in the select statements to identify each occurance. How do I use the UPDATE statement to make the changes? Please help. Thank you.
-
Code:
SQL> select * from xyz;
X
--------------------
lasjkld.abc
jkaasjhd.abcsjdjjsj
u.abc.jaslkdjsysyy
.abcsjdjshdysy.ksjs
SQL> select x, replace(x, '.abc','.defg') newval
2 from xyz;
X NEWVAL
-------------------- --------------------
lasjkld.abc lasjkld.defg
jkaasjhd.abcsjdjjsj jkaasjhd.defgsjdjjsj
u.abc.jaslkdjsysyy u.defg.jaslkdjsysyy
.abcsjdjshdysy.ksjs .defgsjdjshdysy.ksjs
SQL> update xyz set x= replace(x, '.abc','.defg');
4 rows updated.
SQL> commit;
Commit complete.
SQL> select x from xyz;
X
--------------------
lasjkld.defg
jkaasjhd.defgsjdjjsj
u.defg.jaslkdjsysyy
.defgsjdjshdysy.ksjs
Jeff Hunter
-
Code:
update table
set column=replace(column,'.abc','.efgh');
Tomaž
"A common mistake that people make when trying to design something completely
foolproof is to underestimate the ingenuity of complete fools" - Douglas Adams
-
It works. Thank you for your help. Much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|