select sName,sAge from student union 以第一条字段的名称为显示student和teacher的名字和年龄,并组合输出
select tName,tAge from teacher union 排序 去除重复 union all 直接显示连个结果集
多行插入数据 比 insert into 跟简单高效些
insert into Score(studentId,english,math) 为Score表的studentId以及english和math字段添加多条记录
select 1,80,100 union
select 2,90,85 union
...........
把现有表中的数据插入到新表中
select * into newStudent from Student newStudent为新表(newStudent不能存在)Student为现有表
把现有表中的数据插入到已存在的表中
into backStudent select * from student
本文介绍了如何使用SQL的UNION和UNION ALL操作来组合多个查询结果,并讲解了多行数据的批量插入方法,包括从一个现有表复制数据到另一个新表或已存在的表中。
3660

被折叠的 条评论
为什么被折叠?



