关于Union - Union All和store proc [英] que about Union - Union All and store proc

查看:123
本文介绍了关于Union - Union All和store proc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Union和Union All:



有两个表,A和B.

表A有列x1,x2, x3和表B有列x1,x2,x3。

它们有相同的行,a,b,c,d,e。

如何检索所有的distict两个表中的行?

联盟还是联盟?为什么?





商店促销:



如果我有多行由proc返回,我需要处理每一行。

我该怎么做?

Union and Union All :

There are two tables, A and B.
Table A has columns, x1, x2, x3 and table B has columns x1, x2, x3.
They have same rows, a,b,c,d,e.
How can I retrieve all the distict rows from both the tables?
Union or Union all ? why ?


Store proc :

If I have multiple rows returned by a proc and I need to work on each rows.
how can i do that ?

推荐答案

关于你的第一个问题 -



Regarding your 1st question -

UNION removes duplicate records (where all columns in the results are the same), UNION ALL does not.





因此,您需要使用UNION删除重复记录。



关于您的第二个问题,这完全取决于你想要在每一行上做什么。这可以通过

来完成1.使用函数

2.使用游标。



So, you will need to use UNION to remove duplicate records.

Regarding your 2nd question, it totally depends on what do you want to work on the each row. This can be done by
1. Using function(s)
2. Using Cursors.


这篇关于关于Union - Union All和store proc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆