那位高人知道如何在一条sql中替换多处内容
如:content=‘abcdef’ 如何将a换成w,将b换成e,要在一条sql中完成想过用replace,可是一次只能替换一个,那位有啥好方法,多谢了哈!

解决方案 »

  1.   

    蠢办法...替换一次后再替换一次...select regexp_replace(regexp_replace('abcdef','a','w'),'b','e') from dual;
      

  2.   

    select translate('abcdef','ab','we') from dual;
      

  3.   


    --这个好一点点的
    SQL> 
    SQL> select regexp_replace('abcdef',
      2                        (case
      3                          when instr('abcdef', 'a') > 0 then
      4                           'a'
      5                          when instr('abcdef', 'b') > 0 then
      6                           'b'
      7                        end),
      8                        (case
      9                          when instr('abcdef', 'a') > 0 then
     10                           'w'
     11                          when instr('abcdef', 'b') > 0 then
     12                           'e'
     13                        end))
     14    from dual;REGEXP_REPLACE('ABCDEF',(CASEW
    --------------------------------------------------------------------------------
    wbcdefSQL> 
      

  4.   

    3楼,你说的方法好像不行,因为我要替换的内容比较长发来你看看
    Dear mail_name<br>
                      Approve the captioned single request, please click below link:<br>
                      mail_detail_link <br><br>
                      Approve all pending requests, please click below link:<br>
                      mail_list_link <br>;
    要替换的是
    mail_name=result.name
    mail_detail_link=form.form_on_hand_link
    mail_list_link=form.form_on_hand_link
    用你说的替换出来的不对哦