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

【分类】:子查询、多表连接

分析思路

select 查询结果 [设备ID;题目ID;答题结果]
from 从哪张表中查询数据[多个join连接的表]
where 查询条件 [浙江大学用户]

扩展

前往查看:MySQL 嵌套子查询

求解代码

方法一:

in 子查询

#查看所有来自浙江大学的用户题目回答明细情况
select
    device_id,
    question_id,
    result
from user_profile
join question_practice_detail using(device_id)
where device_id in(
    #统计来自浙江大学的用户
    select
        device_id
    from user_profile
    where university = '浙江大学'
)

方法二

select 
    a.device_id,
    question_id,
    result
from user_profile a, question_practice_detail b
where a.device_id = b.device_id
and university = '浙江大学'
全部评论

相关推荐

09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
已注销:bro不如吃顿疯狂星期四
点赞 评论 收藏
分享
评论
28
20
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务