我有两张表QUESTIONS
和STUDENT_ANSWER
。每个表都有PAPER_ID
列和QUESTION_NO
,STUDENT_ANSWER
有一列STUDENT_ID
,如果学生提交论文,那么在STUDENT_ANSWER
表中存储{{1} },STUDENT_ID
,QUESTION_NO
和STUDENT_ANSWER
。
我希望来自PAPER_ID
表格的Answer
QUESTIONS
来自PAPER_ID
'Basic Computer'
的{{1}}和Answers
来自表STUDENT_ANSWER
的存储学生答案其中PAPER_ID
是'Basic Computer
' STUDENT_ID
是1
select
q.answer, s.student_ans
from
questions q, student_answer s
where
s.student_id = 1
and q.paper_id = 'Basic Computer'
and s.paper_id = 'Basic Computer';
答案 0 :(得分:0)
select s.student_id,
q.paper_id,
q.question_no,
q.answer,
s.student_answer
from questions q,
student_answer s
where s.student_id = 1
and q.paper_id = 'Basic Computer'
and s.paper_id = q.paper_id
and s.QUESTION_NO = q.QUESTION_NO
-- result
student_id | paper_id | question_no | answer | student_answer
-------------------------------------------------------------------
1 | Basic Computer | 1 | red | blue
1 | Basic Computer | 2 | green | yellow
1 | Baisc Computer | 3 | blue | brown
这就是你要找的东西吗?