找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 数据库 查看内容

一个sql的update REPLACE的问题

2009-12-14 18:36| 发布者: admin| 查看: 25| 评论: 0|原作者: 冰淇淋

★假设有一张表ttable iddomai......


假设有一张表 ttable
id domain1 domain2
1 abc.com test.abc.com
2 eee.com a.eee.com
update ttable set domain2=REPLACE(domain2,domain1,'test1.com'),domain1='test1.com' where
id=1
update ttable set domain1='test1.com', domain2=REPLACE(domain2,domain1,'test1.com') where
id=2
将会有什么样的结果呢?
id domain1 domain2
1 test1.com test.test1.com
2 test1.com a.eee.com
id=2的记录为什么REPLACE无效了呢? 那是因为domain1在REPLACE之前, 已经由eee.com更新成了
test1.com, 所以REPLACE就无效了.

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 23:34 , Processed in 0.135951 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部