剛開始我也這樣認為,其實不然。
當B表中b字段有值等於'2014-06-02',才執行update A set A.a='2014-06-02';
當B表中b字段沒有值等於'2014-06-02',什麼操作都沒有執行。
其實還是有條件的
update A set A.a='2014-06-02' where exists(select * from B where b='2014-06-02')
update A set A.a=B.b from B where B.b='2014-06-02'等价于:
update A set A.a=B.b from a, B where B.b='2014-06-02'
那么你可以试一下:
select a.*,b.*,a.a,b.b
from a, B where B.b='2014-06-02'
其中a.a,b.b就是你将要更新后的数据。
反复看了你的语句,你的语句还可以直接改为:
update A set A.a='2014-06-02'
这是全表更新。