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

思路:由于有排序需要,所以要使用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'

题目:https://www.nowcoder.com/practice/979b1a5a16d44afaba5191b22152f64a?tpId=199&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D199

posted @ 2022-07-11 15:04  tiansz  阅读(123)  评论(0编辑  收藏  举报