Codice PHP:
SELECT TBL_ARTICLE.*,
SUM(MOVE_ART_IN.pezzi_in) AS TotPezziIn,
SUM(MOVE_ART_OUT.pezzi_out) AS TotPezziOut,
GROUP_CONCAT( MOVE_ART_IN.sn ORDER BY MOVE_ART_IN.id_art_move ASC SEPARATOR '§' ) AS SERIAL_NUMBER_ART
FROM Articoli AS TBL_ARTICLE
LEFT JOIN Move_In AS MOVE_ART_IN ON TBL_ARTICLE.barcode = MOVE_ART_IN.barcode
LEFT JOIN Move_Out AS MOVE_ART_OUT ON TBL_ARTICLE.barcode = MOVE_ART_OUT.barcode
WHERE
TBL_ARTICLE.active = '1'
AND
TBL_ARTICLE.id_cat = '".mysql_escape_String($_POST['category'])."'
AND
TBL_ARTICLE.id_subcat = '".mysql_escape_String($_POST['subcategory'])."'
".$ADD_PARAMETR_QUERY_ARTICOLI."
GROUP BY
TBL_ARTICLE.barcode
ORDER BY
TBL_ARTICLE.articolo ASC
perchè il valore di TotPezziOut risulta triplicato con i seguenti record nelle tabelle??
Move In:
Codice PHP:
id_art_move barcode pezzi_in sn
335 A000000335 2 5734675543-k
336 A000000335 1 3278547632-s
337 A000000335 1 6354353654-y
Move Out:
Codice PHP:
id_art_move barcode sn pezzi_out
1 A000000335 5734675543-k 2
2 A000000335 3278547632-s 3
ovviamente ho tolto quello che non serviva.
Come faccio a ottenere come risultato 5 in Move Out anzichè 15 come effettivamente succede??
grazie mille