如何在sqlserver中使用union查询联合数据

2026-02-15 14:30:57

1、打开sqlserver管理器,菜单栏上的“新建查询”按钮

如何在sqlserver中使用union查询联合数据

2、在查询框中输入:

select kechenghao,kechengming from 课程表

 union 

select xuehao,xingming  from 学生表

如何在sqlserver中使用union查询联合数据

3、两个表中的列数需要一致,点击菜单上的“执行”按钮

如何在sqlserver中使用union查询联合数据

猜你喜欢