新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
union和unionall的區(qū)別
union 和 union all的區(qū)別
相同點(diǎn)和不同點(diǎn)
相同點(diǎn):
union和union all 都是對(duì)于多個(gè)查詢(xún)結(jié)果的并集進(jìn)行操作
不同點(diǎn):
1.union 不會(huì)輸出兩個(gè)結(jié)果并集的重復(fù)行
2.union all 會(huì)輸出兩個(gè)結(jié)果并集的重復(fù)行
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信平臺(tái)小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了懷安免費(fèi)建站歡迎大家使用!
實(shí)驗(yàn)表
字段解釋?zhuān)?/strong>
xh:學(xué)號(hào)
xh:姓名
nl:年齡
create table student(xh number,xm varchar2(4),nl int);
insert into student values(1,'A',21);
insert into student values(2,'B',21);
insert into student values(3,'A',21);
insert into student values(4,'A',21);
insert into student values(5,'A',21);
insert into student values(6,'C',21);
insert into student values(7,'B',21);
查看表
SQL> select * from student;
XH XM NL
---------- ------------ ----------
1 A 21
2 B 21
3 A 21
4 A 21
5 A 21
6 C 21
7 B 21
7 rows selected.
SQL>
例子
union
SQL> select * from student
2 union
3 select * from student where xm='A';
XH XM NL
---------- ------------ ----------
1 A 21
2 B 21
3 A 21
4 A 21
5 A 21
6 C 21
7 B 21
7 rows selected.
SQL>
union all
SQL> select * from student
2 union all
3 select * from student where xm='A';
XH XM NL
---------- ------------ ----------
1 A 21
2 B 21
3 A 21
4 A 21
5 A 21
6 C 21
7 B 21
1 A 21
3 A 21
4 A 21
5 A 21
11 rows selected.
SQL>
文章題目:union和unionall的區(qū)別
本文來(lái)源:http://fisionsoft.com.cn/article/ighjgc.html