I am making a PDF report in PHP.
The problem is that integer values are stored in the database, because that's how I programmed it. The value 1 is equal to Pending, 2 In process and 3 finished.
When I do the query to extract the values in my PDF it brings me the integer values. What I want to do is that in my PDF it shows me the names to which it corresponds.
I managed to implement in the column estado
, but in cuadrilla
I can't implement it. I want to know how to perform a second CASE, or how to do it in order to bring the corresponding name.
SELECT *,
(case
WHEN estado=1 THEN 'Pendiente'
WHEN estado=2 THEN 'En proceso'
WHEN estado=3 THEN 'Terminado'
ELSE 'NO HAY DATOS' END) as estados
FROM sanandre_cmaps.reportes;
The solution is simple, just add a new
CASE
:I recommend you to indent the SQL code to easily understand and modify the code.
Even so, I recommend that you store these types of values in a separate table and relate them through
JOIN
. It will allow you more flexibility when adding or removing values.