Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
Subquery has too many columns; multiple selections in one select statement

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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 ;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!