dtq7387 2013-09-01 19:16
浏览 29
已采纳

如何将Æ替换为表中所有字符串的AE?

I have names in my database like Ætherling or other words where the AE can be in the middle of a string. I'd like to change all instances of Æ to AE. All strings in my database are utf8_unicode.

This is what I currently have:

UPDATE `cards` set name = REPLACE(name,'Æ','AE');

However this only does it for the particular column. How can I do the entire table in MySQL?

  • 写回答

2条回答 默认 最新

  • duanchong3075 2013-09-01 19:42
    关注

    I don't think it have much sense to run query that will update ALL columns, as some of them might have not contain varchar values.

    You must specify your fields explicitly:

    UPDATE `cards` set 
       name = REPLACE(name,'Æ','AE'), 
       other = REPLACE(other,'Æ','AE'), 
       andother = REPLACE(andother,'Æ','AE');
    

    Or you can make use of query from here: Replace all fields in MySQL

    select concat(
           'UPDATE my_table SET ',
           column_name,
           ' = REPLACE(', column_name, ', ''a'', ''e'');')
    from information_schema.columns
    where table_name = 'my_table';
    

    It will generate a set of update queries. You copy them, paste them and run them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于作物生长模型下,有限水资源的最大化粮食产量的资源优化模型建立
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo
  • ¥15 科来模拟ARP欺骗困惑求解
  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式