mysql - Linking table_a one result with table_b multiple results -
so here code have, prints list like:
accounts_id accounts_amount
payments_date payments_amount
$stmt = $db->query("select * debt_accounts inner join debt_payments on payments_account=accounts_id order accounts_id asc, payments_date asc"); $num = $stmt->rowcount(); $current_price = ""; for($i=0;$i<$num;$i++){$row = $stmt->fetch(pdo::fetch_assoc); if($row['accounts_id'] != $current_price) { echo'<h3>'.$row['accounts_id'].' <font></font></h3>'; $current_price = $row['accounts_id']; } echo''.$row['payments_date'].' - '.$row['payments_amount'].' <br />'; }
so want in same query if possible accounts_amount value want
accounts_amount - sum(payments_amount)
any appreciated please.
Comments
Post a Comment