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为报错?这还是个疑问.
![点击这里给我发消息](https://i-blog.csdnimg.cn/blog_migrate/4c28932857b42fc9eeb07f7eb95dcb81.gif)