What is the correct way to perform the following query?
I have a function to which I want to assign a series, if I execute it directly in the engine it generates the div
concatenated, but in the PHP
it throws an error. If I declare it and assign it to a variable it throws a NULL
.
$stmt = $mysqli->prepare("SET @serie=0;
SELECT DISTINCT id_semana,
CONCAT('Semana ', id_semana, ' - ', tramo) AS semana,
CONCAT('div_', @serie:=@serie+1) AS div_
FROM ab_route, ab_mandante
WHERE ab_route.id_mandante = ab_mandante.id and ab_route.id_mandante = 1");