Topic: Requests with variables do not produce result from the first
Good afternoon! Prompt, why in MySQL variables are not from the first processed? Singularities MySQL, adjustments or still that or? It can be corrected?
Here for example such request is taken from the Internet as emulation LAG of function
SELECT mo.id, mo.season; @r AS ` LAG (month) OVER (PARTITION BY season ORDER BY id) `; (@r: = month) AS month FROM ( SELECT m.* FROM (SELECT _season = NULL, @s: = NULL) vars; t_month m ORDER BY season, id ) mo WHERE (CASE WHEN _season IS NULL OR _season <> season THEN @r: = NULL ELSE NULL END IS NULL) AND (_season: = season) IS NOT NULL;
And so at the first performance the rated column turns out empty, and such is watched in all requests where variables are used.