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

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

http://www.nowcoder.com/practice/979b1a5a16d44afaba5191b22152f64a

题目:取出【山东大学】或【男性用户】的信息,并且结果【不去重】。
分析:题目很简单,但也很容易出错。这里【不去重】首先考虑使用union all。
易错点:下面的 or 连接对于既是山东大学又是男性用户的行仅取一次,所以也是去重的。
where university = '山东大学'&nbs***bsp;gender = 'male'
方法一:union all 连接两个 select 子句。
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'


全部评论

相关推荐

祈求顺利毕业😁:简历很好了,多投吧牛油😂。主要是环境不好,大家也卷
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务