$r1 = mysql_query("
SELECT *, SUM(bps.price) as sum FROM accounts
FULL JOIN bps on bps.id = mid
");
echo "Total price: ".$row['price']."<br>" ;
while($row = mysql_fetch_array($r1))
{
echo $row['name']." <b>:::</b> ".$row['mid']." <b>:::</b> ".$row['price'];
echo "<br />";
}
this is my query. I need to get the total(the sum) of the column : bps.price
some of the rows have : 10.5 , others -5.5 etc… in other words some are negative values and others are positive.It will list all the results then at the end display the sum of column price.
Does this work the way you want? I’m not sure which columns belong to which tables, just edit the table names (a / b) as needed…