Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    1

    Unanswered: SELECT Translate

    Hello,

    I am try to replace an email address in the one column for multiple records with new email server name. My question can I use the column name as the first parameter in SELECT TRANSLATE string function?

    here is example :

    SELECT TRANSLATE('column_name', '@old' , '@new') .

    Your help would be greatly appreciated

    Sam.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I'd rather use REPLACE:
    Code:
    UPDATE emails SET
      e_mail = REPLACE(e_mail, '@old', '@new');

  3. #3
    Join Date
    Nov 2005
    Location
    Atlanta, GA USA
    Posts
    20

    REPLACE, not TRANSLATE

    I am try to replace an email address in the one column for multiple records with new email server name. My question can I use the column name as the first parameter in SELECT TRANSLATE string function?

    here is example :

    SELECT TRANSLATE('column_name', '@old' , '@new') .
    What you want is REPLACE, not TRANSLATE.
    Code:
    SELECT REPLACE(column_name, '@old', '@new') FROM SOME_TABLE
    If your data might be in mixed case, you'll probably also want to call LOWER on it before the replacement:
    Code:
    SELECT REPLACE(LOWER(column_name), '@old', '@new') FROM SOME_TABLE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •