Good morning, I'm doing the sum of the elements of a column (which I called MyColumn) in function of another, called "shift". There are three values for shift, so I need the code to return three distinct sum values. For this, I'm using the UNION
function of mysql
. It returns me the values without problems. However, when making the connection in PHP
, the result of shift 3 disappears, only the first two values being returned. Is UNION
the cause of the problem in PHP
? Is there any alternative to using the same or solution for this case?
SELECT sum(MinhaColuna) as 'Soma1' from TabelaX where turno='Um' UNION
SELECT sum(MinhaColuna) as 'Soma2' from TabelaX where turno='Dois' UNION
SELECT sum(MinhaColuna) as 'Soma3' from TabelaX where turno='Três'