lundi 2 février 2015

Query gives correct answer on second run


I have the query SELECT * FROM ( SELECT sort., (CASE concat(question_id,type) WHEN @curType THEN @curRow := coalesce(@curRow,0) + 1 ELSE @curROw := 1 AND @curType := concat(question_id,type) END) + 1 AS rank from (SELECT a. FROM ul_attempt_responses a LEFT JOIN us_attempts b ON a.attempt_id = b.id WHERE b.user_id = 3 AND response IS NOT NULL AND trim(response) != '' AND b.authenticated = 1 ORDER BY question_id, type, id DESC) sort) final WHERE rank = 2;


On my local machine, when the query is executed twice, that is when I get the correct response. But on the Production Server, it works on the first time.


What could be the problem? Is there a problem with the query.





Aucun commentaire:

Enregistrer un commentaire