1.8 union(联合)
插入测试数据
create table emp(
id tinyint unsigned auto_increment primary key,...name varchar(20) not null,
skill set('PHP','mysql','java')
);
insert into emp values (null,...null,'杜甫',2),(null,'白居易',4)
insert into emp values (null,'争青小子',3)
1.8.1 union的使用
作用:将多个select语句结果集纵向联合起来...语法:select 语句 union [选项] select 语句 union [选项] select 语句
-- 查询stu表中的姓名和emp表中姓名 结果自动合并的重复的记录
mysql> select...stuname from stu union select name from emp;
例题:查询上海的男生和北京的女生
-- 方法一:
mysql> select * from stu where