日期:2014-05-18  浏览次数:20502 次

同时更新多个表里的字段

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