题目描述
题目:现在运营想要分别查看学校为山东大学或者性别为男性的用户的device_id、gender、age和gpa数据,请取出相应结果,结果不去重。
根据示例,你的查询应返回以下结果(注意输出的顺序,先输出学校为山东大学再输出性别为男生的信息):
题解
select
device_id, gender, age, gpa
from user_profile
where university='山东大学'
union all
select
device_id, gender, age, gpa
from user_profile
where gender='male'
注意
本题要求不去重
[union选项] -- 与select选项相同, all(全部保留) 和 distinct (去重), 不同的是,默认值为distinct. union默认是去重的
union all: 得到两个查询结果的并集,不会去掉重复行。也不会排序