- SQL code
with a as ( select col1,col2 from table1)update table2 set col3 = 1 where a.col1 = table2.col1update table3 set col4 = 1 where a.col2 = table3.col2
“update table3 set col4 = 1 where a.col2 = table3.col2 ”这段代码是不正确的,请问不用临时表的话,还有更加好的写法吗?
------解决方案--------------------
- SQL code
select col1,col2 into #a from table1update table2 set col3 = 1 from table2 inner join #a a on a.col1 = table2.col1update table3 set col4 = 1 from table3 inner join #a a on where a.col2 = table3.col2