How do I add a query within a CASE in mysql?

2

I have the following query :

select 
'preguntas'.'tipo', 
'preguntas'.'puntaje', 
'preguntas'.'descrip', 
'preguntas'.'numero', 
'preguntas'.'v_f', 
'preguntas'.'seleccion', 
'preguntas'.'desarrollo', 
CASE 'preguntas'.'tipo' 
WHEN 2 THEN (select * from 'preguntas_selecciones' where 'preguntas_selecciones'.'preguntas_id'='preguntas'.'id') 
ELSE 0 
END as 'respuestas' 
from 'preguntas' 
where 'preguntas'.'evaluaciones_id' = 6 
order by 'preguntas'.'numero' asc;

If I put the result in the THEN of any value, it gives me the result correctly, but if I add the query it throws me the following error:

  

Error Code: 1241. Operand should contain 1 column (s)

Will it be possible to make a query within CASE ?

    
asked by Pablo Contreras 06.07.2017 в 06:25
source

1 answer

6

The subquery must return a single column. The * returns more than one column and that is what the error indicates. It is logical that you can not save a set of values in a single column designed to have a single value.
You must change the * by the name of a column in the table preguntas_selecciones

    
answered by 06.07.2017 / 06:48
source