Reputation: 87
Here is what I have at the moment for my select statement:
$sql17="SELECT SUM(TotalProfit)-('$sum14','$sum13') AS TotalProfit FROM jwtdriversbank2";
I can subtract one variable like this with no problem:
$sql17="SELECT SUM(TotalProfit)-'$sum14' AS TotalProfit FROM jwtdriversbank2";
But I want to be able to subtract several variables, how can I do that????
Upvotes: 0
Views: 73
Reputation: 165
$sum_to_substract = $sum14+$sum13; //add all vars that you want to substract
$sql17="SELECT SUM(TotalProfit)-'$sum_to_substract' AS TotalProfit FROM jwtdriversbank2";
Upvotes: 1
Reputation: 7025
Like this?
$sql17="SELECT SUM(TotalProfit)-'$sum14'-'$sum13' AS TotalProfit FROM jwtdriversbank2";
Be careful when you're constructing SQL queries by injecting variables directly like this though, use prepared statements where possible.
Upvotes: 1