Passing a Mysql variable through a mysql query
I'm not sure if the MySQL forum or the PHP is the best place for this query, but have plumbed for here.
I have SQL code that results in the correct output when run in phpMyAdmin
However, when I try to push this through a mysql_query:
it results in the following "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 Week, Competitor, (@csum := @csum + Points) as 'Cum points' from( SELEC' at line 2".
$mike = "set @csum := 0;
Select Week, Competitor, (@csum := @csum + Points) as 'Cum points'
SELECT weekRefTest.week_no as Week, users.user_name as Competitor, SUM(data14.points) as Points
ON data14.player_id = weekRefTest.player_id
AND data14.week = weekRefTest.week_no
INNER JOIN users on weekRefTest.user_id = users.user_id
where users.user_name = 'Mike'
order by Week)b";
Can you use MySql variables using mysql_query or do you have to use a different method?
I'd be grateful for any help you could offer.