原來如此的,UPDATE語句是可以更別名的。

 

 
 
if exists (select name from sysobjects where name='test' and type='u')
drop table test
if exists (select name from sysobjects where name='test1' and type='u')
drop table test1
create  table test
(id int,name varchar(20))
insert into test values (1,'Who am i,test?')

 

create  table test1
(id int,name varchar(20))
insert into test values (1,'Who am i,test1?')

update  test set id=2 from test bsh where test.id=bsh.id

update  test set id=2 from test bsh where id=bsh.id

update  test set id=2 from test bsh,test sh where id=bsh.id and id=sh.id

update  test1 set id=2 from test bsh,test sh where test1.id=bsh.id and

test1.id=sh.iddrop table test1
drop table test 

原來UPDATE語句是可以更新別名的。比如可以這樣執行:

update  bsh set id=2 from test bsh,test sh where bsh.id=sh.id

但爲什麼UPDATE test SET id=2 FROM test bsh,test sh爲報錯?這還是個疑問.

 
 

 

 點擊這裏給我發消息
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章