Reputation: 11
I have a script that sums everything in te field "total" and its ok.
$cleaner = $connection->query("SELECT *,SUM(total) as total FROM ventas where fecha='$datenow'");
but I want to create more filters, when the caja is nails
$cleanerx = $connection->query("SELECT *,SUM(total) as total FROM ventas where fecha='$datenow' and caja='NAILS'");
why is not working, I read the tutorials at php but I don't understand why is not working.
Upvotes: 1
Views: 40
Reputation: 1202
you can do it like this:
$cleaner = $connection->query("SELECT *,SUM(total) as total,(SELECT SUM(total) as total FROM ventas where fecha='$datenow' and caja='NAILS') as totalnails FROM ventas where fecha='$datenow'");
Upvotes: 1