题解 | #查找山东大学或者性别为男生的信息#
查找山东大学或者性别为男生的信息
https://www.nowcoder.com/practice/979b1a5a16d44afaba5191b22152f64a
#先查出条件为:山东大学
select
device_id,gender,age,gpa
from
user_profile
where
user_profile.university = '山东大学'
union all #将上边的查询和下面的查询合成一个结果集(加 all可以有重复的,不加相反)
select
device_id,gender,age,gpa
from
user_profile
where
user_profile.gender = 'male';
两个查询,一个先查出条件为 山东大学的,另个查出性别为男的,然后两个查询中间用 union all 合成一个结果集.
查看20道真题和解析