学习更多MySql语句:https://blog.csdn.net/weixin_45761237/category_11726248.html?spm=1001.2014.3001.5482
学生表
教师表
1、使用 UNION从 "student" 和 "teacher" 表中选取所有不同的class(只有不同的值)
SELECT class
from student
UNION
SELECT class
FROM teacher
2、使用 UNION ALL从 "student" 和 "teacher" 表中选取所有的class(有重复值)
SELECT class
from student
UNION ALL
SELECT class
FROM teacher
3、使用 UNION ALL 从 "student" 和 "teacher" 表中选取所有的A班数据(也有重复的值)
SELECT class,name
from student
WHERE class='A'
UNION ALL
SELECT class,name
FROM teacher
WHERE class='A'