题解 | #浙江大学用户题目回答情况#

浙江大学用户题目回答情况

https://www.nowcoder.com/practice/55f3d94c3f4d47b69833b335867c06c1

该题为多表查询,可以使用两种方法

  1. 方法一使用内连接方法
    select 
     qpd.device_id, qpd.question_id, qpd.result --要显示的结果
    from 
     question_practice_detail as qpd
    inner join
     user_profile as up
    on qpd.device_id = up.device_id and up.university = '浙江大学' --查询条件
    order by question_id;
  2. 可以使用子查询方式,将查询的浙江大学device_id作为条件,去查询答题情况
    select 
     device_id, question_id, result 
    from 
     question_practice_detail
    where 
     device_id
    IN
     (select 
         device_id 
      from 
         user_profile 
      where 
         university = "浙江大学")
    order by question_id;
#sql#
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务