我尝试用相同的“pocde”列减去 2 个不同的表。我已经说明了下面的代码,但它对我不起作用。任何想法?
$result = mysql_query("
SELECT
productlist.*,
SUM(rreturn.total)-SUM(rreturn.total) as totals,
SUM(rsales.tax)-SUM(rreturn.tax) as tax
FROM productlist
LEFT JOIN rsales ON rsales.pcode = productlist.pcode
LEFT JOIN rreturn ON rreturn.pcode = productlist.pcode
GROUP BY pcode
ORDER BY total ASC");
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td style = "background-image:url(images/buts1.png)">'.($row['totals'].'</td>';
echo '<td style = "background-image:url(images/buts1.png)">'.($row['tax'].'</td>';
echo '</tr>';
}