with temp
as
(
select id,inviteid
from Sa_Users
where id=@currentuid
union all
select a.id,a.inviteid
from Sa_Users a
inner join temp on a.id = temp.inviteid
) select id from temp;
这里查出id后 想要update XXX set count=count+1 where id in ( temp中查出的id集合 ) 如何写
sql如何用with as的结果作where条件
答案:2 悬赏:0 手机版
解决时间 2021-03-09 00:56
- 提问者网友:姑娘长的好罪过
- 2021-03-08 14:01
最佳答案
- 五星知识达人网友:杯酒困英雄
- 2021-03-08 15:29
示例代码如下:
;with a as(select * from table_a),
b as (select * from a where id in(3,4,5))
select * from b
记得一定要有逗号间隔开两个查询,最后一个查询前是没有逗号的
;with a as(select * from table_a),
b as (select * from a where id in(3,4,5))
select * from b
记得一定要有逗号间隔开两个查询,最后一个查询前是没有逗号的
全部回答
- 1楼网友:渡鹤影
- 2021-03-08 16:53
搜一下:sql如何用with as的结果作where条件
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯