union联合查询:用来把两个select查询结果集合并成一个结果集
union查询要求:
①多个查询列,个数必须相同结果,
②多个查询列,各个列的数据类型必须一一对应
③union会自动剔除完全重复记录,如果需要保留重复记录,应该使用union all
联合两个表的记录:
select stuName,stuAge from TbStudent unionselect name,age from Student
保留重复记录:
select stuName,stuAge from TbStudent unionallselect stuName,stuAge from TbStudent