V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
zjsxwc
V2EX  ›  MySQL

谁能解释下为什么这条 sql 没有一次把所有数据更新

  •  
  •   zjsxwc ·
    zjsxwc · 2018-10-22 14:45:17 +08:00 · 1963 次点击
    这是一个创建于 1984 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想把 product 表的 detail 字段里的字符串'http://cdn.CDN_URL' 替换为 'CDN_URL',共有 400 多条数据,

    于是执行了这条 sql:

    UPDATE `product` SET detail=REPLACE(detail, 'http://cdn.CDN_URL', 'CDN_URL')
    

    但是执行完后我再次通过这条 sql 搜索

    SELECT * FROM `product`  WHERE detail LIKE '%http://cdn.CDN_URL%'
    ORDER BY `product`.`id`  DESC
    

    返回表示数据库里还有 24 条数据,

    问题:为什么我第一条 sql 没有把数据都改掉?

    +++++++

    发完贴我好像想到了,结贴,应该是原先有数据'http://cdn.http://cdn.CDN_URL'这种数据,汗。。

    2 条回复    2018-11-23 22:32:03 +08:00
    ywlvs
        1
    ywlvs  
       2018-11-15 16:44:14 +08:00
    涨见识了!
    xyjincan
        2
    xyjincan  
       2018-11-23 22:32:03 +08:00 via Android
    😒
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5633 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 01:42 · PVG 09:42 · LAX 18:42 · JFK 21:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.