一个sql的update REPLACE的问题

来源:互联网 发布:淘宝网鞋子批发 编辑:程序博客网 时间:2024/04/30 10:08

假设有一张表 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就无效了.