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

with as 的用法解决办法

2012-10-11 
with as 的用法SQL codewitha as (select col1,col2 from table1)update table2 set col3 1 where a.col

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 

热点排行