题解 | #查找山东大学或者性别为男生的信息#
查找山东大学或者性别为男生的信息
https://www.nowcoder.com/practice/979b1a5a16d44afaba5191b22152f64a
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'
主要的错误点会在不去重,一般拿到这个题看到或,都会下意识先选or,但是在where那里使用了or的话,同时满足两个条件的人只会被选择一次,所以在这里使用上下连接,分别查出满足两个条件的单个表,再用union all把这两个表相连就会得到不去重的表