简体   繁体   English

如何联接三个表以查看分数?

[英]How to join three tables to view scores?

i have 3 tables questions , scores and users. 我有3个表格的问题,分数和用户。 questions table is something like this: 问题表是这样的:
q_id q_text option1 option2 option3 option4 answer_id
in the above row answer_id means, if answer_id value is 2 ,option2 is correct answer for question 在上一行的answer_id表示,如果answer_id值为2,则option2是问题的正确答案
user table is: 用户表是:
user_id user_name<br>password . user_id user_name<br>password
.

Scores table is: 分数表是:
user_id q_id answer_id

in scores table scores are stored into following 在分数表中,分数存储在以下内容中
urer_id=1;q_id=1,2,5,6;answer_id=2,4,3,1 urer_id = 1; q_id = 1,2,5,6; answer_id = 2,4,3,1
my question is how to view each q_id of q_text + answer_id of option rows + user name? 我的问题是如何查看q_text的每个q_id +选项行的answer_id +用户名?

Is that what you're trying to accomplish ? 这就是您要完成的工作吗?

SELECT answer.q_id, answer.answer_id,user.user_name 
FROM answer 
JOIN user ON user.user_id = answer.user_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM