29-3 union的使用

Posted Strugglinggirl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了29-3 union的使用相关的知识,希望对你有一定的参考价值。

联合结果集union (集合运算符)

-------------------------使用union联合结果集----------------
select tsname,tsgender,tsage from TblStudent
union all
select fname,fgender,fage from MyStudent
--------------------------------------------

--使用union和union all都能进行联合,区别在于:使用union联合去除重复、重新排列数据,而union all不会去除重复也不会重新排列。
select select tsname,tsgender,tsage from TblStudent
union 
select fname,fgender,fage from MyStudent

 

以上是关于29-3 union的使用的主要内容,如果未能解决你的问题,请参考以下文章

使用 with as 优化SQL

union在重构代码中的使用技巧

sql 查询结果合并union all用法_数据库技巧

关于MySQL的关联查询

SQL语句:使用了union all后怎么分组排序

mypy 错误 - 尽管使用了“Union”,但类型不兼容