题解 | #查找山东大学或者性别为男生的信息#

查找山东大学或者性别为男生的信息

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 合成一个结果集.

全部评论
楼主这个思路很优秀了
点赞 回复 分享
发布于 2023-06-01 09:48 黑龙江
感谢lz 无私分享
点赞 回复 分享
发布于 2023-06-01 09:48 黑龙江

相关推荐

03-24 17:57
门头沟学院 Java
yakuso:你这头像哈哈哈
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务