思路

由于要返回学校为上东大学,或性别为男的学生并且不去重。这意味着不能直接用 or 连接两个条件,要先写两个独立的查询,再用union all 连接。

Tips: union 会去除两个查询的重复值,union all 不会去除重复值

实现

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"