【SQL】Update中使用表别名、如何用表中一列值替换另一列的所有值

Update中使用表别名

select中的表别名:

select * from TableA as ta

update中的表别名:

update ta
set ta.key = 1
from TableA as ta

如何用表中一列值替换另一列的所有值

不同表列替换:

update ta
set ta.key1 = tb.key2
from TableA as ta, TableB as tb
where ta.key = tb.key

同一表列替换:

update ta
set ta.key1 = tb.key2
from TableA as ta, TableA as tb
where ta.key = tb.key

 

 

 

posted @ 2013-06-25 13:54  编程的厨子  阅读(3135)  评论(0编辑  收藏  举报