0
I can make a query
using 1 case
to various fields? The fields are of the type int
.
If not, I can do it in php?
Query
select *,
(case (pergunta1,pergunta2)
when 1 then 'Ótimo'
when 2 then 'Bom'
when 3 then 'Regular'
when 4 then 'Ruim'
END) as pergunta1,pergunta2 from tabela
It wouldn’t make the BD return texts that way, it would be unfeasible to work with translation packages, maintenance... Play this in a
array
in PHP, much simpler.– Papa Charlie
Would that be?
$arr = array('', 'Ótimo', 'Bom', 'Regular', 'Ruim');
echo $arr[$pergunta1];
– Eduardo Santos
Yes, just remove the empty index:
$arr = array(1 => 'Ótimo', 2 => 'Bom', 3 => 'Regular', 4=> 'Ruim');
– Papa Charlie