Using ";" in a query that is in php

2

I have this query:

SET @runtot:=0;
SELECT Fecha, (@runtot := @runtot + Numero) AS 'N'
FROM Tabla
WHERE 'ID' = 2

I am using this query on a page of . But since there is a ; in the query (at the end of SET @runtot:=0; ), the query fails me when I try it on the page of - in Navicat it works perfectly.

What can I use instead of the ; to be able to use it in

asked by CalvT 07.01.2016 в 19:29
source

1 answer

2

Well (finally!) I could solve it in the following way:

SELECT t.Fecha, @runtot:=@runtot + t.count AS N
FROM (SELECT Fecha, Numero AS 'count'
  FROM Tabla
  WHERE 'ID' = 1
  ORDER BY Fecha) t
JOIN (SELECT @runtot := 0 AS dummy) dummy
    
answered by 07.01.2016 / 20:30
source