首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

同时更新多个表里的字段,该如何解决

2012-01-14 
同时更新多个表里的字段 updatetable1ta1table2ta2table3ta3setta1.value11 ,ta2.value11 ,ta3.value20

同时更新多个表里的字段

update   table1   ta1
              table2   ta2
              table3   ta3
set   ta1.value1   =   '1 ',ta2.value1   =   '1 ',ta3.value2   =   '0 '  
where   ta1.value1   =   ta1.value1  
    and   ta1.value2   =   ta2.value2  
    and   ta1.value1   =   ta3.value1  

有没有实现这样功能的SQL语句?上边的语句跑不通,只是个想象的样子...
(同时更新多个表,而且这几个表间字段有关联)

[解决办法]
不能这样执行,只能
update table1 set ta1.value1 = '1 '
from table1 ta1 ,table2 ta2,table3 ta3
where ta1.value1 = ta1.value1
and ta1.value2 = ta2.value2
and ta1.value1 = ta3.value1

热点排行