简体   繁体   中英

How to join three tables to view scores?

i have 3 tables questions , scores and users. 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
user table is:
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
my question is how to view each q_id of q_text + answer_id of option rows + user name?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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