3个回答
展开全部
使用游标来循环
DECLARE @id as int
DECLARE corss_cursor CURSOR FOR select Id from a
OPEN corss_cursor
FETCH NEXT FROM corss_cursor INTO @id
WHILE @@FETCH_STATUS = 0
Begin
--------查找B
SELECT * from b WHERE id=@id
-------继续下一条
FETCH NEXT FROM corss_cursor INTO @id
End
CLOSE corss_cursor
DEALLOCATE corss_cursor
DECLARE @id as int
DECLARE corss_cursor CURSOR FOR select Id from a
OPEN corss_cursor
FETCH NEXT FROM corss_cursor INTO @id
WHILE @@FETCH_STATUS = 0
Begin
--------查找B
SELECT * from b WHERE id=@id
-------继续下一条
FETCH NEXT FROM corss_cursor INTO @id
End
CLOSE corss_cursor
DEALLOCATE corss_cursor
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
declare @xxx int、varchar
select @xxx=a.x=from a
....
定义变量保存上一步取出的值用到下一步就可以了,大概
select @xxx=a.x=from a
....
定义变量保存上一步取出的值用到下一步就可以了,大概
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询