Disclaimer: Sorry if this is a simple question, or a badly worded question. I'm a noob and I didn't know how to word this problem, so I didn't know how to google it.
I have two tables. Math.question and Math.choice.
Math.question contains a questiontext column, as well as correctanswerid, wronganswerid1... and so on.
questiontext correctanswerid wronganswerID1 wronganswerid2
(question text 101 102 103
goes here)
Math.choice contains the id of the choice, and the choices text.
id choicetext
101 (text goes here)
102 (text goes here)
...
I want to select questiontext from math.question, and the choicetext. so it'll show something like this:
questiontext correctanswerText wronganswer1text wronganswer2text
(question text) (choice text) (choice text) (choice text)
I have tried this:
select * from math.choice
where id in (
select CorrectAnswer_Choice_ID, Foil1_Choice_ID, Foil2_Choice_ID, Foil3_Choice_ID
from math.question where id=301
);
I got the subquery has too many columns error. I'm not really sure where to go from here.
You need multiple joins. Something like this:
select c.*, q1. choicetext, q2.choicetext, q3.choicetext
from math.choice c left join
math.question q1
on q1.id = c.CorrectAnswer_Choice_ID left join
math.question q2
on q2.id = c.Foil1_Choice_ID left join
math.question q3
on q3.id = c.Foil3_Choice_ID ;