ho fatto cosi:
codice:
$Q_A = '';
while ($Riga = mysql_fetch_array ($row)){
$Q_A .= $Riga['Q_A'].",";
}
$Q_A = substr($Q_A, 0, -1);
$Q_A = explode(",",$Q_A);
echo "a: ".$Q_A[0]."</br>";
echo "b: ".$Q_A[1]."</br>";
echo "c: ".$Q_A[2]."</br>";
Cosi funziona...però ho una curiosità!!!
Utilizzando union, devo, per ogni SUM o risultato qualsiasi, utilizzare tante select quante ne occorrono, oppure posso ottimizzare in questo modo?
Perchè in pratica devo fare 14 SUM, ce ne sono alcune che non utilizzano nessuna discrimintante di ricerca particolare, e quindi le vorrei inserire all'interno di una sola select, però mi restituisce questo errore:
"The used SELECT statements have a different number of columns"
codice:
SELECT
SUM(Quantita_A) as Q_A
from TB_A
where Prefisso_A IN ('1','2','3','4','5') and
Q_A = '204' and F_A = '1' and S_ = 'a'
UNION
SELECT
SUM(Quantita_B) as Q_A,
SUM(Quantita_C) as Q_A
from TB_A
where Q_A = '204' and F_A = '1' and S_ = 'a'
UNION
SELECT
SUM(Quantita_D) as Q_A
from TB_A
where Prefisso_D IN ('6','7') and
Q_A = '204' and F_A = '1' and S_ = 'a'
Quindi?Come mi comporto?
Grazie ancora