多表查询 子查询
多表查询
法一表联立的关键是正确连接和正确查询
select q.device_id, q.question_id, q.result
from question_practice_detail as q
inner join user_profile as u
on q.device_id = u.device_id
where u.university = '浙江大学';
法二子查询的关键是锁定两张表的相同列,然后利用筛选条件选出要找的行的位置,最后利用位置选中另一张表中的数据
select device_id, question_id, result
from question_practice_detail
where device_id in (
select device_id
from user_profile
where university = '浙江大学'
)
法一表联立的关键是正确连接和正确查询
select q.device_id, q.question_id, q.result
from question_practice_detail as q
inner join user_profile as u
on q.device_id = u.device_id
where u.university = '浙江大学';
法二子查询的关键是锁定两张表的相同列,然后利用筛选条件选出要找的行的位置,最后利用位置选中另一张表中的数据
select device_id, question_id, result
from question_practice_detail
where device_id in (
select device_id
from user_profile
where university = '浙江大学'
)
全部评论
相关推荐
点赞 评论 收藏
分享
![](https://images.nowcoder.com/head/header0004.png?x-oss-process=image/resize,m_mfit,h_100,w_100)
点赞 评论 收藏
分享
2024-12-24 15:53
郑州轻工业大学 后端 点赞 评论 收藏
分享
点赞 评论 收藏
分享