mysql_DML_select_union

使用union可以将多个select 语句的查询结果集组合成一个结果集。
select 字段列表1 from table1
union [all]
select 字段列表2 from table2...
说明:字段列表1与字段列表2的字段个数必须相同,且具有相同的数据类型。合
并产生的新结果集的字段名与字段列表1中的字段名对应。

eg:

select stu_id,stu_name from teacher

union 

select stu_id,stu_name from stu;

union 和union all  前者去重 后者不去重

posted @ 2016-09-22 17:56  D.零下的小书屋  阅读(122)  评论(0编辑  收藏  举报