update statement problem
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: update statement problem

  1. #1
    Join Date
    Jul 2001
    Location
    Montreal
    Posts
    218

    Question 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.

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    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
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    Jul 2001
    Location
    Slovenia
    Posts
    422
    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

  4. #4
    Join Date
    Jul 2001
    Location
    Montreal
    Posts
    218
    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
  •  



Click Here to Expand Forum to Full Width