Jump to content

SUM()


maxudaskin

Recommended Posts

Is it possible to use SUM() and WHERE in the same query if they are both using the same column?

 

<?php
$query      = mysql_query("SELECT type, pid, SUM(totaltime) as sumValue FROM pireps GROUP BY `pid` WHERE type = '0' AND `pid` = '$poster_pid'");
$hours      = mysql_fetch_array($query) or die ("MySQL Error on line 472: " . mysql_error()); // Line 472
?>

 

Outputs

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.grable/vzoom/virtualzoom.net/comm/forum.php on line 473

MySQL Error on line 472: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE type = '0' AND `pid` = '0100'' at line 1

Link to comment
https://forums.phpfreaks.com/topic/98648-sum/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.