#进阶10:联合查询 /* union联合 将多条查询语句的结果合并成一个结果 语法: 查询1 union 查询2 union 查询3 ... 应用场景:要查询的结果来自于多个表,且多个表没有直接的连接关系,但查询的信息一致 特点: 1、多条查询语句的列数要一致、每一列的类型和顺序要对应 2、union默认去重 */ USE myemployees; #引入的案例:查询部门编号>90或邮箱包含a的员工信息 SELECT * FROM employees WHERE email LIKE ‘%a%‘ OR department_id > 90; #自动去重 SELECT * FROM employees WHERE email LIKE ‘%a%‘ UNION SELECT * FROM employees WHERE department_id > 90; SELECT * FROM employees WHERE email LIKE ‘%a%‘ UNION ALL SELECT * FROM employees WHERE department_id > 90;