dowm41315 2013-09-19 15:03
浏览 70
已采纳

在所有数据库mysql中用另一个字符串替换字符串

I have a database which I want to export to CSV File.

In one of the fields ringPics, I have values as

"abc.png,zxc.png"

Now when I export to CSV it mix up columns.

Since the database is very big , i can't replace , manually.

I want to do something like this replace , with /\

What changes need to be done with below query

UPDATE `rings` SET `ringPicDir`= REPLACE("ringPicDir", ',', '/\')
  • 写回答

1条回答 默认 最新

  • duan0530 2013-09-19 15:05
    关注

    try this

     UPDATE `rings` SET `ringPicDir`= REPLACE( ringPicDir, ',', '/\')
                                             ^^^---no quotes here , you can use backticks also
    

    or this

    UPDATE `rings` SET `ringPicDir` = if (ringPicDir Like '%,%' ,  REPLACE( ringPicDir, ',', '/\'), ringPicDir)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥20 OPENVPN连接问题