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.
你可以这样做:
$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'");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.