DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Replacing values

  1. #1
    Join Date
    Jun 2003
    Posts
    132

    Replacing values

    Hello,

    How would I go about replacing values in all rows that contain value for example "INC" and replace it to "INC."

    Example
    "IBM INC" and replace it to "IBM INC."

    Thanks

    Roman

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    try some simple sql

    update table_name set column_name = 'IBM INC.' where column_name = 'IBM INC';

  3. #3
    Join Date
    Jun 2003
    Posts
    132
    That will not work, because we have about 20,000 unique company names and it would take me one week to do it one by one. But thanks for your suggestion.

    Roman

  4. #4
    Join Date
    Jan 2002
    Location
    Up s**t creek
    Posts
    1,525
    Jim
    Oracle Certified Professional
    "Build your reputation by helping other people build theirs."

    "Sarcasm may be the lowest form of wit but its still funny"

    Click HERE to vist my website!

  5. #5
    Join Date
    Jun 2003
    Posts
    132
    I used the wildcard to identify all records with INC value. I do not know how to replace all found record with '%INC' to "INC."

    ----------------------
    SELECT name
    FROM company
    WHERE name like '%INC'
    -----------------------


    Thanks

    Roman

  6. #6
    Join Date
    Jan 2000
    Location
    Chester, England.
    Posts
    818
    not predictable - what if there's a company called 'ZINC'? Use Replace and make sure you check for the space before the 'I' in 'INC'

  7. #7
    Join Date
    Jun 2003
    Posts
    132
    Is there any way you can help me with the code.

    Thanks

    Roman

  8. #8
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Not sure REPLACE will do what is wanted -
    e.g. "INCREMENTAL CONFUSION INC" would end up as "INC.REMENTAL CONFUSION INC."

    This might do:
    UPDATE company SET name=name||'.'
    WHERE name LIKE '%INC';

  9. #9
    Join Date
    Jun 2003
    Posts
    132
    That worked great.

    Thanks

    Roman

  10. #10
    Join Date
    Jan 2002
    Location
    Up s**t creek
    Posts
    1,525
    Code:
    SQL> create table test (company varchar2(20));
    
    Table created.
    
    SQL> insert into test values ('A1 Potatos Inc');
    
    1 row created.
    
    SQL> insert into test values ('Incorp Air Inc');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> select company from test;
    
    COMPANY
    --------------------
    A1 Potatos Inc
    Incorp Air Inc
    
    SQL> select replace(company,' Inc',' Inc.') from test;
    
    REPLACE(COMPANY,'INC','INC.')
    ------------------------------------------------------
    A1 Potatos Inc.
    Incorp Air Inc.
    Jim
    Oracle Certified Professional
    "Build your reputation by helping other people build theirs."

    "Sarcasm may be the lowest form of wit but its still funny"

    Click HERE to vist my website!

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