Sunday, 29 September 2013

What is wrong with this MySQL query syntax?

What is wrong with this MySQL query syntax?

$db = mysql_select_db("remote");
if(!$db) {
die("Unable to select database");
}
$query = "SET @cumulative_sum := 0;
SELECT timestamp,
@cumulative_sum := @cumulative_sum + value AS cumulative_sum
FROM remote.historical
WHERE timestamp>= CURDATE()";
$result = mysql_query($qry);
When I use this query in my HeidiSQL, it output okay...running cumulative
over current day, but when I copied this code into php file, web browser
outputs:
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 'SELECT
timestamp, @cumulative_sum := @cumulative_sum + value AS cumulative_sum F'
at line 1
What is wrong with this code?

No comments:

Post a Comment