当前位置: 代码迷 >> Sql Server >> with as 的用法解决办法
  详细解决方案

with as 的用法解决办法

热度:30   发布时间:2016-04-27 10:52:28.0
with as 的用法
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
  相关解决方案