当前位置:Gxlcms > 数据库问题 > mysql_DML_select_union

mysql_DML_select_union

时间:2021-07-01 10:21:17 帮助过:1人阅读

使用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  前者去重 后者不去重

mysql_DML_select_union

标签:

人气教程排行