如何编写存储过程? [英] How to write a stored procedure?
本文介绍了如何编写存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将查询的每一行传递到另一个sql并将每个结果存储在一个表中,最后
查询结果表?
例子,
表学生如下
没有ID
- -
1 1 * 2 * 1
2 2 * 3 * 2
从学生表中选择id
然后将每行id传递给sql以从中选择不同的id每一行
然后将此结果1 2存储在临时表中
最后用数据查询表,
id
-
1
2
2
获得不同的身份证数量。
谢谢..
Hi,
How to pass each row of a query into another sql and store each result in a table and finally
querying the result table?
example,
table student as below
no id
-- --
1 1*2*1
2 2*3*2
select id from student table
then pass each row id into a sql to select distinct id from each row
then store this result 1 2 in a temporary table
finally query the table with data,
id
--
1
2
2
3
to get distinct id count.
thanks..
推荐答案
解决方案被删除,因为OP更新了问题。
Solution deleted as OP has updated the question.
这篇关于如何编写存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文