题解 | 查找山东大学或者性别为男生的信息
查找山东大学或者性别为男生的信息
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的时候,对于既满足山东大学,又满足性别是男的时候,不会对这个条数据进行第二次查询。因此导致数据丢失
查看30道真题和解析