Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

294
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda