题目:取出【山东大学】或【男性用户】的信息,并且结果【不去重】。
分析:题目很简单,但也很容易出错。这里【不去重】首先考虑使用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'